Package net.java.textilej.parser

Examples of net.java.textilej.parser.Attributes


      return 0;
    }
    if (!getDialect().isFilterGenerativeContents()) {
      SortedMap<String,String> glossary = new TreeMap<String, String>(state.getGlossaryTerms());
     
      builder.beginBlock(BlockType.DEFINITION_LIST, new Attributes(null,
          null, style == null ? null : "list-style: " + style, null));
      Attributes nullAttributes = new Attributes();
      for (Map.Entry<String, String> ent: glossary.entrySet()) {
        builder.beginBlock(BlockType.DEFINITION_TERM, nullAttributes);
        builder.characters(ent.getKey());
        builder.endBlock();
       
View Full Code Here


  private static class FootnoteReferenceReplacementTokenProcessor extends PatternBasedElementProcessor {
    @Override
    public void emit() {
      String footnote = group(1);
      String htmlId = state.getFootnoteId(footnote);
      builder.beginSpan(SpanType.SUPERSCRIPT, new Attributes(null,"footnote",null,null));
      builder.link("#"+htmlId, footnote);
      builder.endSpan();
    }
View Full Code Here

      String href = parts.length > 1?parts[1]:parts[0];
      String tip = parts.length > 2?parts[2]:null;
      if (text == null || text.length() == 0) {
        text = href;
      }
      Attributes attributes = new LinkAttributes();
      attributes.setTitle(tip);
      getBuilder().link(attributes,href, text);
    }
View Full Code Here

    private EscapeProcessor() {
    }
   
    @Override
    public void emit() {
      getBuilder().beginSpan(SpanType.MONOSPACE, new Attributes());
      String group = group(1);
      if (group == null) {
        group = group(2);
      }
      getBuilder().characters(group);
View Full Code Here

    }
   
    @Override
    public void emit() {
      for (SpanType type: spanType) {
        getBuilder().beginSpan(type, new Attributes());
      }
      if (nesting) {
        getDialect().emitMarkupLine(parser, state,state.getLineCharacterOffset()+getStart(this), getContent(this), 0);
      } else {
        getDialect().emitMarkupText(parser, state, getContent(this));
View Full Code Here

    if (dialect.isEmptyLine(line) || (offset == 0 && line.charAt(0) != ' ')) {
      setClosed(true);
      return 0;
    }
    if (blockLineCount++ == 0) {
      builder.beginBlock(BlockType.PREFORMATTED, new Attributes());
    }
    builder.characters(line.substring(1));
    builder.characters("\n");
    return -1;
  }
View Full Code Here

   
    int level = matcher.group(1).length();
   
    String text = matcher.group(2);
   
    final Attributes attributes = new Attributes();
    if (attributes.getId() == null) {
      attributes.setId(state.getIdGenerator().newId("h"+level,line.substring(offset)));
    }
    builder.beginHeading(level,attributes);
    builder.characters(text);
    builder.endHeading();
   
View Full Code Here

  @Override
  public int processLineContent(String line,int offset) {
    boolean continuation = false;
    if (blockLineCount == 0) {
      listState = new Stack<ListState>();
      Attributes attributes = new Attributes();
      String listSpec = matcher.group(1);
      char lastChar = listSpec.charAt(listSpec.length()-1);
      int level = calculateLevel(listSpec);
      BlockType type = calculateType(lastChar);
      BlockType itemType = calculateItemType(lastChar);
     
      if (type == BlockType.BULLETED_LIST && '-' == lastChar) {
        attributes.setCssStyle("list-style: square");
      }
     
      offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
   
      listState.push(new ListState(1,type,itemType));
      builder.beginBlock(type, attributes);
     
      adjustLevel(lastChar, level, type, itemType);
    } else {
      Matcher matcher = startPattern.matcher(line);
      if (!matcher.matches()) {
        setClosed(true);
        return 0;
      }
      String listSpec = matcher.group(1);
      char lastChar = listSpec.charAt(listSpec.length()-1);
      int lineLevel = calculateLevel(listSpec);
      BlockType type = calculateType(lastChar);
      BlockType itemType = calculateItemType(lastChar);
     
      offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
     
      continuation = adjustLevel(lastChar, lineLevel, type, itemType);
    }
    ++blockLineCount;
   
    ListState listState = this.listState.peek();
    if (!continuation && listState.openItem) {
      listState.openItem = false;
      builder.endBlock();
    }
    if (!listState.openItem) {
      listState.openItem = true;
      builder.beginBlock(listState.itemType, new Attributes());
    }
   
    String definition = null;
    int definitionOffset = -1;
    if (listState.itemType == BlockType.DEFINITION_TERM) {
      // detect definition on same line as term
      Matcher definitionMatcher = definitionPattern.matcher(line);
      if (offset > 0) {
        definitionMatcher.region(offset, line.length());
      }
      if (definitionMatcher.find()) {
        line = line.substring(offset,definitionMatcher.start(1));
        offset = 0;
        definition = definitionMatcher.group(2);
        definitionOffset = definitionMatcher.start(2);
      }
    }
    if (definition == null) {
      dialect.emitMarkupLine(getParser(),state,line, offset);
    } else {
      dialect.emitMarkupLine(getParser(),state,offset,line,0)
    }
   
    if (definition != null) {
      listState.openItem = false;
      builder.endBlock();
     
      adjustLevel(' ',listState.level,BlockType.DEFINITION_LIST,BlockType.DEFINITION_ITEM);
     
      listState = this.listState.peek();
      if (listState.openItem) {
        builder.endBlock();
      }
      listState.openItem = true;
      builder.beginBlock(listState.itemType, new Attributes());
     
      dialect.emitMarkupLine(parser, state,definitionOffset, definition,0);
    }
   
    return -1;
View Full Code Here

      lineLevel != previousState.level || previousState.type != type || previousState.itemType != itemType;
      previousState = listState.peek()) {
     
      if (lineLevel > previousState.level) {
        if (!previousState.openItem) {
          builder.beginBlock(previousState.itemType, new Attributes());
          previousState.openItem = true;
        }

        Attributes blockAttributes = new Attributes();
        if (type == BlockType.BULLETED_LIST && '-' == lastChar) {
          blockAttributes.setCssStyle("list-style: square");
        }   
        listState.push(new ListState(previousState.level+1,type,itemType));
        builder.beginBlock(type,blockAttributes);
      } else if (lineLevel == previousState.level && previousState.type == type && previousState.itemType != itemType) {
        if (previousState.openItem) {
          builder.endBlock();
          previousState.openItem = false;
        }
        previousState.itemType = itemType;
      } else {
        if (lineLevel == previousState.level && lastChar == ':') {
          // this is possibly a continuation of the previous item.
          if (previousState.itemType != BlockType.DEFINITION_ITEM && previousState.itemType != BlockType.DEFINITION_TERM) {
            // we found a continuation
            continuation = true;
            break;
          }
        }
        closeOne();
        if (listState.isEmpty()) {
          Attributes blockAttributes = new Attributes();
          if (type == BlockType.BULLETED_LIST && '-' == lastChar) {
            blockAttributes.setCssStyle("list-style: square");
          }   
          listState.push(new ListState(1,type,itemType));
          builder.beginBlock(type,blockAttributes);
        }
      }
View Full Code Here

  }

  @Override
  public int processLineContent(String line,int offset) {
    if (blockLineCount == 0) {
      Attributes attributes = new Attributes();
     
      builder.beginBlock(BlockType.PARAGRAPH, attributes);
    } else if (nestedBlock != null) {
      int returnOffset = nestedBlock.processLine(line, offset);
      if (nestedBlock.isClosed()) {
View Full Code Here

TOP

Related Classes of net.java.textilej.parser.Attributes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.