use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder in project mylyn.docs by eclipse.
the class TextileLanguageTest method testBug50XHTMLCompliance.
@Test
public void testBug50XHTMLCompliance() throws Exception {
StringWriter writer = new StringWriter();
MarkupParser parser = new MarkupParser(new TextileLanguage());
final HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer);
builder.setXhtmlStrict(true);
builder.setEmitDtd(true);
builder.setHtmlDtd("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
parser.setBuilder(builder);
parser.parse("!<image.png!:http://foo.bar");
String html = writer.toString();
assertTrue(html.contains("<a href=\"http://foo.bar\"><img style=\"border-width: 0px;text-align: left;\" alt=\"\" src=\"image.png\"/></a>"));
}
use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder in project mylyn.docs by eclipse.
the class TextileLanguageTest method testBlockCodeWithTabsFormatted.
/**
* bug 320007
*/
@Test
public void testBlockCodeWithTabsFormatted() throws IOException {
StringWriter out = new StringWriter();
HtmlDocumentBuilder documentBuilder = new HtmlDocumentBuilder(out, true);
parser.setBuilder(documentBuilder);
parser.parse("bc. one\n\ttwo\n\nthree");
String html = out.toString();
assertTrue(html.contains("one\n\ttwo"));
}
use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder in project statecharts by Yakindu.
the class HubspotDocumentBuilder method beginHeading.
/**
* <p>
* The begin of a heading has been encountered. If it is an H1 heading, we
* have to write the first part of the contents template into the stream.
* Placeholders <em>${h1.id}</em> and <em>${h1.title}</em> have to be
* replaced by actual values.
* </p>
* <p>
* <strong>Please note:</strong> At this point the title text is not yet
* known! This is only the case at {@link #endHeading()}.
* </p>
*/
@Override
public void beginHeading(final int level, final Attributes attributes) {
isProcessingHeading = true;
final String id = attributes.getId();
if (!isEarlySeparator) {
isFollowingEarlySeparator = isEarlySeparator;
isEarlySeparator = level == 1 && "%EARLY_SEPARATOR%".equals(attributes.getCssStyle());
} else {
isFollowingEarlySeparator = isEarlySeparator;
isEarlySeparator = false;
}
if (isEarlySeparator) {
/*
* Collect everything between the early separator and the next H1 in
* another writer.
*/
s2 = new StringWriter();
w2 = new PrintWriter(s2);
h2 = new HtmlDocumentBuilder(w2);
} else
currentHeading = new Heading(resource, level, id);
if (level == 1) {
if (!isFirstH1 && !isFollowingEarlySeparator)
w.print(resolveHeadingIdAndTitle(contentsTemplate[1], 1, id, null));
else
isFirstH1 = false;
if (!isEarlySeparator) {
w.println(resolveHeadingIdAndTitle(contentsTemplate[0], 1, id, null));
if (isFollowingEarlySeparator) {
w2.close();
w.println(s2.toString());
h2 = null;
w2 = null;
}
super.beginHeading(level, attributes);
}
} else
super.beginHeading(level, attributes);
}
Aggregations