use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder 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.builder.HtmlDocumentBuilder in project mylyn.docs by eclipse.
the class HtmlParserTest method assertCanParseSomething.
protected void assertCanParseSomething(HtmlParser parser) throws IOException, SAXException {
StringWriter out = new StringWriter();
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(out);
builder.setEmitAsDocument(false);
parser.parse(new InputSource(new StringReader("<body><p>test</p></body>")), builder);
String result = out.toString();
Assert.assertEquals("<p>test</p>", result.trim());
}
use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder in project mylyn.docs by eclipse.
the class FontElementStrategyTest method assertHtmlFromSpanWithCss.
void assertHtmlFromSpanWithCss(String expectedHtml, String spanCssStyle) {
StringWriter out = new StringWriter();
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(out);
SpanStrategy spanStrategy = strategy.spanStrategy();
spanStrategy.beginSpan(builder, SpanType.SPAN, new Attributes(null, null, spanCssStyle, null));
builder.characters("test");
spanStrategy.endSpan(builder);
assertEquals(expectedHtml, out.toString());
}
use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder 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;
}
use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder in project mylyn.docs by eclipse.
the class CommonMarkLanguageDocumentOffsetsTest method assertSpanOffsets.
private void assertSpanOffsets(int offset, int length, String expectedHtml, String markup) {
final AtomicReference<Locator> spanLocator = new AtomicReference<Locator>();
CommonMarkLanguage language = new CommonMarkLanguage();
MarkupParser parser = new MarkupParser(language);
StringWriter out = new StringWriter();
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(out) {
@Override
public void beginSpan(SpanType type, Attributes attributes) {
assertNull(spanLocator.get());
spanLocator.set(new LocatorImpl(getLocator()));
super.beginSpan(type, attributes);
}
};
builder.setEmitAsDocument(false);
parser.setBuilder(builder);
parser.parse(markup);
assertEquals(expectedHtml, out.toString());
Locator locator = spanLocator.get();
assertNotNull(locator);
assertEquals(offset, locator.getDocumentOffset());
int actualLength = locator.getLineSegmentEndOffset() - locator.getLineCharacterOffset();
assertEquals(length, actualLength);
}
Aggregations