use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder in project mylyn.docs by eclipse.
the class SourceBlocksTest method mockBlock.
private SourceBlock mockBlock(final BlockType blockType, final String startString) {
return new SourceBlock() {
@Override
public void process(ProcessingContext context, DocumentBuilder builder, LineSequence lineSequence) {
builder.beginBlock(blockType, new Attributes());
for (Line line : lineSequence.with(not(LinePredicates.empty()))) {
builder.characters(line.getText());
}
builder.endBlock();
}
@Override
public boolean canStart(LineSequence lineSequence) {
return lineSequence.getCurrentLine() != null && lineSequence.getCurrentLine().getText().startsWith(startString);
}
};
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder in project mylyn.docs by eclipse.
the class HtmlLanguageTest method newDocumentBuilderIsFormatting.
@Test
public void newDocumentBuilderIsFormatting() {
Writer out = new StringWriter();
DocumentBuilder builder = new HtmlLanguage().createDocumentBuilder(out, true);
builder.beginDocument();
builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
builder.characters("test");
builder.endBlock();
builder.endDocument();
assertEquals(loadResourceContent("newDocumentBuilderIsFormatting.xml"), out.toString());
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder in project mylyn.docs by eclipse.
the class HtmlLanguageTest method newDocumentBuilderIsNotFormatting.
@Test
public void newDocumentBuilderIsNotFormatting() {
Writer out = new StringWriter();
DocumentBuilder builder = new HtmlLanguage().createDocumentBuilder(out, false);
builder.beginDocument();
builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
builder.characters("test");
builder.endBlock();
builder.endDocument();
assertEquals(loadResourceContent("newDocumentBuilderIsNotFormatting.xml"), out.toString());
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder in project mylyn.docs by eclipse.
the class HtmlParserTest method assertParse.
private void assertParse(String expected, String content) {
StringWriter out = new StringWriter();
DocumentBuilder builder = new HtmlDocumentBuilder(out);
parse(content, builder);
assertEquals(expected, out.toString());
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder in project mylyn.docs by eclipse.
the class HtmlLanguageBuilderTest method spanToBoldTransformation.
@Test
public void spanToBoldTransformation() {
StringWriter writer = new StringWriter();
HtmlLanguage language = builder.add(BlockType.PARAGRAPH).add(SpanType.BOLD).document("", "").name("Test").create();
DocumentBuilder builder = language.createDocumentBuilder(writer);
builder.beginDocument();
addSpanWithCssFontWeightBold(builder);
builder.characters(" ");
addSpanWithCssColor(builder);
builder.endDocument();
assertEquals("<b>test</b> inside font", writer.toString());
}
Aggregations