Search in sources :

Example 36 with Attributes

use of org.eclipse.mylyn.wikitext.parser.Attributes in project mylyn.docs by eclipse.

the class ParagraphBlock method processLineContent.

@Override
protected int processLineContent(String line, int offset) {
    // start of block
    if (blockLineCount == 0) {
        builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
    }
    // empty line: start new block
    if (markupLanguage.isEmptyLine(line)) {
        setClosed(true);
        return 0;
    }
    for (Block block : markupLanguage.getParagraphBreakingBlocks()) {
        if (block.canStart(line, offset)) {
            setClosed(true);
            return offset;
        }
    }
    // next line, does not convert to line break
    if (blockLineCount > 0) {
        // $NON-NLS-1$
        builder.characters("\n");
    }
    getMarkupLanguage().emitMarkupLine(getParser(), state, line, offset);
    blockLineCount++;
    return -1;
}
Also used : Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) Block(org.eclipse.mylyn.wikitext.parser.markup.Block)

Example 37 with Attributes

use of org.eclipse.mylyn.wikitext.parser.Attributes in project mylyn.docs by eclipse.

the class DocBookDocumentBuilderTest method testDiv.

public void testDiv() {
    builder.beginDocument();
    builder.beginBlock(BlockType.DIV, new Attributes());
    builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
    builder.characters("foo");
    // PARAGRAPH
    builder.endBlock();
    builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
    builder.characters("bar");
    // PARAGRAPH
    builder.endBlock();
    // DIV
    builder.endBlock();
    builder.endDocument();
    String docbook = out.toString();
    String expectedContent = "<para>foo</para><para>bar</para>";
    assertEquals(DOCBOOK_BEGIN_CHAPTER + expectedContent + DOCBOOK_END_CHAPTER, docbook);
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) ListAttributes(org.eclipse.mylyn.wikitext.parser.ListAttributes) TableAttributes(org.eclipse.mylyn.wikitext.parser.TableAttributes)

Example 38 with Attributes

use of org.eclipse.mylyn.wikitext.parser.Attributes in project mylyn.docs by eclipse.

the class DocBookDocumentBuilderTest method testOrderedListUpperromanType.

public void testOrderedListUpperromanType() {
    builder.beginDocument();
    ListAttributes listAttributes = new ListAttributes();
    listAttributes.setCssStyle("list-style-type: upper-roman;");
    builder.beginBlock(BlockType.NUMERIC_LIST, listAttributes);
    builder.beginBlock(BlockType.LIST_ITEM, new Attributes());
    builder.characters("item");
    // LI
    builder.endBlock();
    // OL
    builder.endBlock();
    builder.endDocument();
    String docbook = out.toString();
    String expectedContent = "<orderedlist numeration=\"upperroman\"><listitem><para>item</para></listitem></orderedlist>";
    assertEquals(DOCBOOK_BEGIN_CHAPTER + expectedContent + DOCBOOK_END_CHAPTER, docbook);
}
Also used : ListAttributes(org.eclipse.mylyn.wikitext.parser.ListAttributes) LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) ListAttributes(org.eclipse.mylyn.wikitext.parser.ListAttributes) TableAttributes(org.eclipse.mylyn.wikitext.parser.TableAttributes)

Example 39 with Attributes

use of org.eclipse.mylyn.wikitext.parser.Attributes in project mylyn.docs by eclipse.

the class DocBookDocumentBuilderTest method testTableClass.

public void testTableClass() {
    builder.beginDocument();
    TableAttributes tableAttributes = new TableAttributes();
    tableAttributes.appendCssClass("foo");
    builder.beginBlock(BlockType.TABLE, tableAttributes);
    builder.beginBlock(BlockType.TABLE_ROW, new Attributes());
    builder.beginBlock(BlockType.TABLE_CELL_NORMAL, new Attributes());
    builder.characters("text");
    // cell
    builder.endBlock();
    // row
    builder.endBlock();
    // table
    builder.endBlock();
    builder.endDocument();
    String docbook = out.toString();
    String expectedContent = "<informaltable role=\"foo\"><tr><td>text</td></tr></informaltable>";
    assertEquals(DOCBOOK_BEGIN_CHAPTER + expectedContent + DOCBOOK_END_CHAPTER, docbook);
}
Also used : LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) ListAttributes(org.eclipse.mylyn.wikitext.parser.ListAttributes) TableAttributes(org.eclipse.mylyn.wikitext.parser.TableAttributes) TableAttributes(org.eclipse.mylyn.wikitext.parser.TableAttributes)

Example 40 with Attributes

use of org.eclipse.mylyn.wikitext.parser.Attributes in project mylyn.docs by eclipse.

the class DocBookDocumentBuilderTest method testOrderedListArabicType.

public void testOrderedListArabicType() {
    builder.beginDocument();
    ListAttributes listAttributes = new ListAttributes();
    listAttributes.setCssStyle("list-style-type: decimal;");
    builder.beginBlock(BlockType.NUMERIC_LIST, listAttributes);
    builder.beginBlock(BlockType.LIST_ITEM, new Attributes());
    builder.characters("item");
    // LI
    builder.endBlock();
    // OL
    builder.endBlock();
    builder.endDocument();
    String docbook = out.toString();
    String expectedContent = "<orderedlist numeration=\"arabic\"><listitem><para>item</para></listitem></orderedlist>";
    assertEquals(DOCBOOK_BEGIN_CHAPTER + expectedContent + DOCBOOK_END_CHAPTER, docbook);
}
Also used : ListAttributes(org.eclipse.mylyn.wikitext.parser.ListAttributes) LinkAttributes(org.eclipse.mylyn.wikitext.parser.LinkAttributes) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) ListAttributes(org.eclipse.mylyn.wikitext.parser.ListAttributes) TableAttributes(org.eclipse.mylyn.wikitext.parser.TableAttributes)

Aggregations

Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)428 LinkAttributes (org.eclipse.mylyn.wikitext.parser.LinkAttributes)248 ImageAttributes (org.eclipse.mylyn.wikitext.parser.ImageAttributes)223 Test (org.junit.Test)176 Matcher (java.util.regex.Matcher)33 ListAttributes (org.eclipse.mylyn.wikitext.parser.ListAttributes)29 TableAttributes (org.eclipse.mylyn.wikitext.parser.TableAttributes)17 StringWriter (java.io.StringWriter)14 BlockType (org.eclipse.mylyn.wikitext.parser.DocumentBuilder.BlockType)12 HtmlDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder)10 Pattern (java.util.regex.Pattern)9 DocumentBuilder (org.eclipse.mylyn.wikitext.parser.DocumentBuilder)9 SpanStrategies (org.eclipse.mylyn.wikitext.html.internal.SpanStrategies)8 Block (org.eclipse.mylyn.wikitext.parser.markup.Block)8 SpanStrategy (org.eclipse.mylyn.wikitext.html.internal.SpanStrategy)6 SubstitutionBlockStrategy (org.eclipse.mylyn.wikitext.html.internal.SubstitutionBlockStrategy)6 SubstitutionSpanStrategy (org.eclipse.mylyn.wikitext.html.internal.SubstitutionSpanStrategy)6 SubstitutionWithoutCssSpanStrategy (org.eclipse.mylyn.wikitext.html.internal.SubstitutionWithoutCssSpanStrategy)6 TableCellAttributes (org.eclipse.mylyn.wikitext.parser.TableCellAttributes)6 EventDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder)6