use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder in project mylyn.docs by eclipse.
the class HtmlParserTest method assertParseEventOrder.
private void assertParseEventOrder(String content, Object... expectedEventTypes) {
final List<Object> actualEventTypes = new ArrayList<>();
DocumentBuilder builder = new NoOpDocumentBuilder() {
@Override
public void beginBlock(BlockType type, Attributes attributes) {
actualEventTypes.add(type);
}
@Override
public void beginSpan(SpanType type, Attributes attributes) {
actualEventTypes.add(type);
}
@Override
public void characters(String text) {
actualEventTypes.add(text);
}
@Override
public void endBlock() {
actualEventTypes.add(END_BLOCK);
}
@Override
public void endSpan() {
actualEventTypes.add(END_SPAN);
}
};
parse(content, builder);
assertEquals(ImmutableList.copyOf(expectedEventTypes), actualEventTypes);
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder in project mylyn.docs by eclipse.
the class CommonMarkLanguage method processContent.
@Override
public void processContent(MarkupParser parser, String markupContent, boolean asDocument) {
checkNotNull(parser);
checkNotNull(markupContent);
DocumentBuilder builder = checkNotNull(parser.getBuilder());
if (asDocument) {
builder.beginDocument();
}
SourceBlocks sourceBlocks = CommonMark.sourceBlocks();
ProcessingContext context = createContext(sourceBlocks, markupContent);
sourceBlocks.process(context, builder, LineSequence.create(markupContent));
if (asDocument) {
builder.endDocument();
}
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder in project mylyn.docs by eclipse.
the class MarkdownRoundTripTest method emitAsMarkdown.
private String emitAsMarkdown(String characters) {
StringWriter markupWriter = new StringWriter();
DocumentBuilder documentBuilder = language.createDocumentBuilder(markupWriter);
documentBuilder.characters(characters);
documentBuilder.flush();
return markupWriter.toString();
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder in project mylyn.docs by eclipse.
the class HtmlLanguageTest method newDocumentBuilder.
@Test
public void newDocumentBuilder() {
Writer out = new StringWriter();
DocumentBuilder builder = new HtmlLanguage().createDocumentBuilder(out);
assertNotNull(builder);
assertTrue(builder instanceof HtmlDocumentBuilder);
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder in project mylyn.docs by eclipse.
the class HtmlLanguageBuilderTest method document.
@Test
public void document() {
HtmlSubsetLanguage subsetLanguage = (HtmlSubsetLanguage) builder.add(BlockType.PARAGRAPH).document("<div>", "</div>").name("Test").create();
StringWriter writer = new StringWriter();
DocumentBuilder documentBuilder = subsetLanguage.createDocumentBuilder(writer);
documentBuilder.beginDocument();
documentBuilder.characters("test");
documentBuilder.endDocument();
assertEquals("<div>test</div>", writer.toString());
}
Aggregations