use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder in project mylyn.docs by eclipse.
the class AbstractSaxParserTest method performTest.
protected void performTest(String html, String expectedResult) throws IOException, SAXException {
parser.parse(sourceForHtml(html), builder, true);
String generatedMarkup = out.toString();
assertEquals(expectedResult, generatedMarkup);
MarkupParser markupParser = new MarkupParser(new TextileLanguage());
StringWriter out = new StringWriter();
HtmlDocumentBuilder htmlBuilder = new HtmlDocumentBuilder(out);
htmlBuilder.setEmitAsDocument(false);
markupParser.setBuilder(htmlBuilder);
markupParser.parse(generatedMarkup);
}
use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder in project mylyn.docs by eclipse.
the class HtmlDocumentBuilder2Test method testLinkRel.
public void testLinkRel() throws Exception {
// link-specific rel
StringWriter out = new StringWriter();
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(out);
builder.beginDocument();
builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
LinkAttributes attributes = new LinkAttributes();
attributes.setRel("nofollow");
builder.link(attributes, "http://www.foo.bar", "Foo Bar");
builder.endBlock();
builder.endDocument();
String html = out.toString();
assertTrue(html.contains("<a href=\"http://www.foo.bar\" rel=\"nofollow\">Foo Bar</a>"));
// default link rel
out = new StringWriter();
builder = new HtmlDocumentBuilder(out);
builder.setLinkRel("nofollow");
builder.beginDocument();
builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
attributes = new LinkAttributes();
builder.link(attributes, "http://www.foo.bar", "Foo Bar");
builder.endBlock();
builder.endDocument();
html = out.toString();
assertTrue(html.contains("<a href=\"http://www.foo.bar\" rel=\"nofollow\">Foo Bar</a>"));
// both link-specific and default link ref
out = new StringWriter();
builder = new HtmlDocumentBuilder(out);
builder.setLinkRel("nofollow");
builder.beginDocument();
builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
attributes = new LinkAttributes();
attributes.setRel("foobar");
builder.link(attributes, "http://www.foo.bar", "Foo Bar");
builder.endBlock();
builder.endDocument();
html = out.toString();
assertTrue(html.contains("<a href=\"http://www.foo.bar\" rel=\"foobar nofollow\">Foo Bar</a>"));
// no rel at all
out = new StringWriter();
builder = new HtmlDocumentBuilder(out);
builder.beginDocument();
builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
attributes = new LinkAttributes();
builder.link(attributes, "http://www.foo.bar", "Foo Bar");
builder.endBlock();
builder.endDocument();
html = out.toString();
assertTrue(html.contains("<a href=\"http://www.foo.bar\">Foo Bar</a>"));
}
use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder in project mylyn.docs by eclipse.
the class MarkupToEclipseHelpMojoTest method createBuilder.
@Test
public void createBuilder() {
markupToEclipseHelp.copyrightNotice = UUID.randomUUID().toString();
markupToEclipseHelp.title = UUID.randomUUID().toString();
markupToEclipseHelp.htmlFilenameFormat = "$1.test.html";
HtmlDocumentBuilder builder = markupToEclipseHelp.createRootBuilder(new StringWriter(), "test", "");
assertEquals(markupToEclipseHelp.copyrightNotice, builder.getCopyrightNotice());
assertEquals(markupToEclipseHelp.title, builder.getTitle());
assertEquals(markupToEclipseHelp.htmlFilenameFormat, builder.getHtmlFilenameFormat());
}
use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder in project mylyn.docs by eclipse.
the class MarkupToEclipseHelpMojoTest method configureStylesheetUrlsWithRelativePath.
@Test
public void configureStylesheetUrlsWithRelativePath() {
markupToEclipseHelp.stylesheetUrls = Arrays.asList("bar.css");
HtmlDocumentBuilder builder = mock(HtmlDocumentBuilder.class);
markupToEclipseHelp.configureStylesheets(builder, "one/two");
ArgumentCaptor<Stylesheet> captor = ArgumentCaptor.forClass(Stylesheet.class);
verify(builder).addCssStylesheet(captor.capture());
assertEquals("../../bar.css", captor.getValue().getUrl());
}
use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder in project mylyn.docs by eclipse.
the class MarkupToEclipseHelpMojoTest method configureStylesheetUrls.
@Test
public void configureStylesheetUrls() {
markupToEclipseHelp.stylesheetUrls = Arrays.asList("test/foo.css", "bar.css");
HtmlDocumentBuilder builder = mock(HtmlDocumentBuilder.class);
markupToEclipseHelp.configureStylesheets(builder, "");
verify(builder, times(2)).addCssStylesheet(any(Stylesheet.class));
}
Aggregations