Search in sources :

Example 1 with SimplifiedHtmlDocumentBuilder

use of org.eclipse.mylyn.wikitext.commonmark.internal.spec.SimplifiedHtmlDocumentBuilder in project mylyn.docs by eclipse.

the class AbstractSourceSpanTest method assertParseToHtml.

public void assertParseToHtml(String expected, String markup) {
    StringWriter writer = new StringWriter();
    HtmlDocumentBuilder builder = new SimplifiedHtmlDocumentBuilder(writer);
    builder.setEmitAsDocument(false);
    builder.beginDocument();
    InlineParser parser = new InlineParser(span, new AllCharactersSpan());
    List<Inline> inlines = parser.parse(ProcessingContext.builder().build(), new TextSegment(ImmutableList.of(new Line(1, 0, markup))));
    for (Inline inline : inlines) {
        inline.emit(builder);
    }
    builder.endDocument();
    assertEquals(expected, writer.toString());
}
Also used : Line(org.eclipse.mylyn.wikitext.commonmark.internal.Line) StringWriter(java.io.StringWriter) SimplifiedHtmlDocumentBuilder(org.eclipse.mylyn.wikitext.commonmark.internal.spec.SimplifiedHtmlDocumentBuilder) TextSegment(org.eclipse.mylyn.wikitext.commonmark.internal.TextSegment) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) SimplifiedHtmlDocumentBuilder(org.eclipse.mylyn.wikitext.commonmark.internal.spec.SimplifiedHtmlDocumentBuilder)

Example 2 with SimplifiedHtmlDocumentBuilder

use of org.eclipse.mylyn.wikitext.commonmark.internal.spec.SimplifiedHtmlDocumentBuilder in project mylyn.docs by eclipse.

the class CommonMarkAsserts method createDocumentBuilder.

private static DocumentBuilder createDocumentBuilder(StringWriter out) {
    HtmlDocumentBuilder builder = new SimplifiedHtmlDocumentBuilder(out);
    builder.setDocumentHandler(new HtmlDocumentHandler() {

        @Override
        public void endDocument(HtmlDocumentBuilder builder, XmlStreamWriter writer) {
        }

        @Override
        public void beginDocument(HtmlDocumentBuilder builder, XmlStreamWriter writer) {
        }
    });
    return builder;
}
Also used : SimplifiedHtmlDocumentBuilder(org.eclipse.mylyn.wikitext.commonmark.internal.spec.SimplifiedHtmlDocumentBuilder) HtmlDocumentHandler(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentHandler) XmlStreamWriter(org.eclipse.mylyn.wikitext.util.XmlStreamWriter) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) SimplifiedHtmlDocumentBuilder(org.eclipse.mylyn.wikitext.commonmark.internal.spec.SimplifiedHtmlDocumentBuilder)

Aggregations

SimplifiedHtmlDocumentBuilder (org.eclipse.mylyn.wikitext.commonmark.internal.spec.SimplifiedHtmlDocumentBuilder)2 HtmlDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder)2 StringWriter (java.io.StringWriter)1 Line (org.eclipse.mylyn.wikitext.commonmark.internal.Line)1 TextSegment (org.eclipse.mylyn.wikitext.commonmark.internal.TextSegment)1 HtmlDocumentHandler (org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentHandler)1 XmlStreamWriter (org.eclipse.mylyn.wikitext.util.XmlStreamWriter)1