use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder in project mylyn.docs by eclipse.
the class HtmlLanguageBuilderTest method addSpanFontWithSpanSupport.
@Test
public void addSpanFontWithSpanSupport() {
StringWriter writer = new StringWriter();
HtmlLanguage language = builder.addSpanFont().add(BlockType.PARAGRAPH).add(SpanType.SPAN).document("", "").name("Test").create();
DocumentBuilder builder = language.createDocumentBuilder(writer);
builder.beginDocument();
builder.beginSpan(SpanType.SPAN, new Attributes());
builder.characters("test");
builder.endSpan();
builder.characters(" ");
addSpanWithCssColor(builder);
builder.endDocument();
assertEquals("<span>test</span> <font color=\"purple\">inside font</font>", writer.toString());
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder in project mylyn.docs by eclipse.
the class HtmlLanguageBuilderTest method spanSubstitution.
@Test
public void spanSubstitution() {
StringWriter writer = new StringWriter();
HtmlLanguage language = builder.addSpanFont().add(SpanType.DELETED).addSubstitution(SpanType.DELETED, "strike").document("", "").name("Test").create();
DocumentBuilder builder = language.createDocumentBuilder(writer);
builder.beginDocument();
builder.beginSpan(SpanType.DELETED, new Attributes());
builder.characters("test");
builder.endSpan();
assertEquals("<strike>test</strike>", writer.toString());
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder in project mylyn.docs by eclipse.
the class HtmlLanguageBuilderTest method spanToCompositeTransformation.
@Test
public void spanToCompositeTransformation() {
StringWriter writer = new StringWriter();
HtmlLanguage language = builder.add(BlockType.PARAGRAPH).add(SpanType.BOLD).add(SpanType.MONOSPACE).add(SpanType.EMPHASIS).document("", "").name("Test").create();
DocumentBuilder builder = language.createDocumentBuilder(writer);
builder.beginDocument();
builder.beginSpan(SpanType.SPAN, new Attributes(null, null, "font-weight:bold; font-family: courrier, monospace;font-style:italic;unknown: rule", null));
builder.characters("test");
builder.endSpan();
builder.endDocument();
assertEquals("<b><tt><em>test</em></tt></b>", writer.toString());
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder in project mylyn.docs by eclipse.
the class FontElementStrategyTest method spanStrategyNestedSpansBuildsCorrectHtml.
@Test
public void spanStrategyNestedSpansBuildsCorrectHtml() {
StringWriter out = new StringWriter();
DocumentBuilder builder = HtmlLanguage.builder().add(BlockType.PARAGRAPH).addSpanFont().name("Test").create().createDocumentBuilder(out);
builder.beginSpan(SpanType.SPAN, new Attributes(null, null, "color:blue;", null));
builder.beginSpan(SpanType.SPAN, new Attributes(null, null, "", null));
builder.beginSpan(SpanType.SPAN, new Attributes(null, null, "font-size: 15px", null));
builder.characters("test");
builder.endSpan();
builder.endSpan();
builder.endSpan();
assertEquals("<font color=\"blue\"><font size=\"15px\">test</font></font>", out.toString());
}
use of org.eclipse.mylyn.wikitext.parser.DocumentBuilder in project mylyn.docs by eclipse.
the class ConfluenceLanguageIntegrationTest method assertHtmlToConfluence.
private void assertHtmlToConfluence(boolean parseAsDocument) {
HtmlLanguage htmlLanguage = HtmlLanguage.builder().add(BlockType.PARAGRAPH).add(SpanType.BOLD).name("Test").create();
MarkupParser parser = new MarkupParser(htmlLanguage);
Writer confluenceOut = new StringWriter();
DocumentBuilder confuenceBuilder = new ConfluenceLanguage().createDocumentBuilder(confluenceOut);
parser.setBuilder(confuenceBuilder);
parser.parse("<html><body>some text <b>bold here</b> more text</body></html>", parseAsDocument);
assertEquals("some text *bold here* more text\n\n", confluenceOut.toString());
}
Aggregations