Package net.java.textilej.parser

Examples of net.java.textilej.parser.Attributes


  }

  @Override
  public int processLineContent(String line,int offset) {
    if (blockLineCount == 0) {
      Attributes attributes = new Attributes();
      builder.beginBlock(BlockType.TABLE, attributes);
    } else {
      matcher = tableRowPattern.matcher(line);
      if (!matcher.matches()) {
        setClosed(true);
        return 0;
      }
    }
    ++blockLineCount;
   
    String textileLine = offset==0?line:line.substring(offset);
    Matcher rowMatcher = TABLE_ROW_PATTERN.matcher(textileLine);
    if (!rowMatcher.find()) {
      setClosed(true);
      return 0;
    }
   
    builder.beginBlock(BlockType.TABLE_ROW, new Attributes());
   
    do {
      int start = rowMatcher.start();
      if (start == textileLine.length()-1) {
        break;
      }
   
      String text = rowMatcher.group(1);
      int textOffset = rowMatcher.start(1);
     
      Attributes attributes = new Attributes();
      state.setLineCharacterOffset(start);
      builder.beginBlock(BlockType.TABLE_CELL_NORMAL, attributes);

      dialect.emitMarkupLine(getParser(), state,textOffset, text, 0);
     
View Full Code Here


   
    while (quoteBlockState.size() > level) {
      closeOne();
    }
    while (quoteBlockState.size() < level) {
      openOne(new Attributes());
    }
   
    BlockState blockState = quoteBlockState.peek();
    if (!blockState.paraOpen) {
      builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
      blockState.paraOpen = true;
    } else if (blockLineCount != 0) {
      builder.lineBreak();
    }
    ++blockLineCount;
View Full Code Here

  @Override
  public int processLineContent(String line,int offset) {
    if (blockLineCount++ == 0) {
      offset = matcher.start(1);
      builder.beginBlock(BlockType.PREFORMATTED, new Attributes());
    } else {
      Matcher endMatcher = endPattern.matcher(line);
      if (endMatcher.matches()) {
        setClosed(true);
        return endMatcher.start(1);
View Full Code Here

      this.nesting = nesting;
    }
   
    @Override
    public void emit() {
      Attributes attributes = new Attributes();
      configureAttributes(this, attributes);
      getBuilder().beginSpan(spanType, attributes);
      if (nesting) {
        getDialect().emitMarkupLine(parser, state, state.getLineCharacterOffset() + getStart(this),
            getContent(this), 0);
View Full Code Here

  }

  @Override
  public int processLineContent(String line,int offset) {
    if (blockLineCount == 0) {
      Attributes attributes = new Attributes();
      if (matcher.group(1) != null) {
        // 0-offset matches may start with the "table. " prefix.
        Textile.configureAttributes(attributes,matcher, 2,true);
        offset = line.length();
      }
      builder.beginBlock(BlockType.TABLE, attributes);
    } else if (dialect.isEmptyLine(line)) {
      setClosed(true);
      return 0;
    }
    ++blockLineCount;
   
    if (offset == line.length()) {
      return -1;
    }

    String textileLine = offset==0?line:line.substring(offset);
    Matcher rowMatcher = TABLE_ROW_PATTERN.matcher(textileLine);
    if (!rowMatcher.find()) {
      setClosed(true);
      return 0;
    }
    {
      TableRowAttributes rowAttributes = new TableRowAttributes();
      int rowStart = rowMatcher.start();
      if (rowStart > 0) {
        // if the row content starts somewhere in the line then it's likely
        // that we have some row-level attributes
        Matcher rowAttributesMatcher = rowAttributesPattern.matcher(textileLine);
        if (rowAttributesMatcher.matches()) {
          Textile.configureAttributes(rowAttributes, rowAttributesMatcher, 1, true);
        }
      }
      builder.beginBlock(BlockType.TABLE_ROW, rowAttributes);
    }
   
    do {
      int start = rowMatcher.start();
      if (start == textileLine.length()-1) {
        break;
      }
 
      String colSpan = rowMatcher.group(1);
      String rowSpan = rowMatcher.group(2);
      String alignment = rowMatcher.group(3);
      String headerIndicator = rowMatcher.group(8);
      String text = rowMatcher.group(9);
      int textLineOffset = rowMatcher.start(9);
     
      boolean header = headerIndicator != null && ("_".equals(headerIndicator) || "|".equals(headerIndicator));
     
      String textAlign = null;
      if (alignment != null) {
        if (alignment.equals("<>")) {
          textAlign = "text-align: center;";
        } else if (alignment.equals(">")) {
          textAlign = "text-align: right;";
        } else if (alignment.equals("<")) {
          textAlign = "text-align: left;";
        } else if (alignment.equals("^")) {
          textAlign = "text-align: top;";
        }
      }
      TableCellAttributes attributes = new TableCellAttributes();
      attributes.setCssStyle(textAlign);
      attributes.setRowspan(rowSpan);
      attributes.setColspan(colSpan);
      Textile.configureAttributes(attributes, rowMatcher,4,false);
     
      state.setLineCharacterOffset(start);
      builder.beginBlock(header?BlockType.TABLE_CELL_HEADER:BlockType.TABLE_CELL_NORMAL, attributes);
     
View Full Code Here

     
      offset = matcher.start(LINE_REMAINDER_GROUP);
      extended = matcher.group(EXTENDED_GROUP) != null;
     
      builder.beginBlock(BlockType.QUOTE, attributes);
      builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
      paraOpen = true;
    }
    if (dialect.isEmptyLine(line)) {
      if (!extended) {
        setClosed(true);
        return 0;
      } else {
        if (paraOpen) {
          builder.endBlock(); // para
          paraOpen = false;
        }
        return 0;
      }
    } else if (extended && Textile.explicitBlockBegins(line,offset)) {
      setClosed(true);
      return offset;
    }
    if (blockLineCount != 0) {
      if (paraOpen) {
        builder.lineBreak();
      } else {
        builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
        paraOpen = true;
      }
    }
    ++blockLineCount;
   
View Full Code Here

  }

  @Override
  public int processLineContent(String line,int offset) {
    if (blockLineCount == 0) {
      Attributes attributes = new Attributes();

      Textile.configureAttributes(attributes,matcher, 1, true);
      offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
      extended = matcher.group(EXTENDED_GROUP) != null;
     
      builder.beginBlock(BlockType.PREFORMATTED, attributes);
      builder.beginBlock(BlockType.CODE, new Attributes());
    }
    if (dialect.isEmptyLine(line) && !extended) {
      setClosed(true);
      return 0;
    } else if (extended && Textile.explicitBlockBegins(line,offset)) {
View Full Code Here

  }

  @Override
  public int processLineContent(String line,int offset) {
    if (blockLineCount == 0) {
      Attributes attributes = new Attributes();
 
      Textile.configureAttributes(attributes,matcher, 1,true);
      offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
      extended = matcher.group(EXTENDED_GROUP) != null;
     
View Full Code Here

  }

  @Override
  public int processLineContent(String line,int offset) {
    if (blockLineCount == 0) {
      Attributes attributes = new Attributes();
      if (offset == 0) {
        // 0-offset matches may start with the "hn. " prefix.
        level = Integer.parseInt(matcher.group(1));
        Textile.configureAttributes(attributes,matcher, 2,true);
        offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);
      }
      if (attributes.getId() == null) {
        attributes.setId(state.getIdGenerator().newId("h"+level,line.substring(offset)));
      }
      builder.beginHeading(level, attributes);
    }
    if (dialect.isEmptyLine(line)) {
      setClosed(true);
View Full Code Here

  }

  @Override
  public int processLineContent(String line,int offset) {
    if (blockLineCount == 0) {
      Attributes attributes = new Attributes();
      attributes.setCssClass("footnote");

      // 0-offset matches may start with the "fnnn. " prefix.
      footnote = matcher.group(1);
      attributes.setId(state.getFootnoteId(footnote));

      Textile.configureAttributes(attributes,matcher, 2,true);
      offset = matcher.start(LINE_REMAINDER_GROUP_OFFSET);

      builder.beginBlock(BlockType.PARAGRAPH, attributes);
      builder.beginSpan(SpanType.SUPERSCRIPT, new Attributes());
      builder.characters(footnote);
      builder.endSpan();
      builder.characters(" ");
    }
    if (dialect.isEmptyLine(line)) {
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.