Search in sources :

Example 16 with HtmlDocumentBuilder

use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder in project mylyn.docs by eclipse.

the class AsciiDocLanguageTestBase method parseAsciiDocToHtml.

protected static String parseAsciiDocToHtml(String markup, MarkupParser parser) {
    StringWriter out = new StringWriter();
    HtmlDocumentBuilder builder = new HtmlDocumentBuilder(out);
    builder.setEmitAsDocument(false);
    parser.setBuilder(builder);
    parser.parse(markup);
    return out.toString();
}
Also used : StringWriter(java.io.StringWriter) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder)

Example 17 with HtmlDocumentBuilder

use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder in project mylyn.docs by eclipse.

the class ConfluenceLanguageTest method testHyperlinkMailtoWithBase.

@Test
public void testHyperlinkMailtoWithBase() throws URISyntaxException {
    StringWriter out = new StringWriter();
    HtmlDocumentBuilder builder = new HtmlDocumentBuilder(out);
    builder.setBase(new URI("/"));
    parser.setBuilder(builder);
    parser.parse("[test|mailto:foo@bar.com]");
    assertTrue(out.toString().contains("<a href=\"mailto:foo@bar.com\">test</a>"));
}
Also used : StringWriter(java.io.StringWriter) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) URI(java.net.URI) Test(org.junit.Test) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)

Example 18 with HtmlDocumentBuilder

use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder in project mylyn.docs by eclipse.

the class ConfluenceLanguageTest method testHangOnBug318695.

/**
 * bug 318695
 */
@Test
public void testHangOnBug318695() throws IOException {
    String content = Resources.toString(ConfluenceLanguageTest.class.getResource("resources/bug318695.confluence"), Charsets.UTF_8);
    parser.setBuilder(new HtmlDocumentBuilder(new StringWriter()));
    parser.parse(new StringReader(content));
// if we reach here we didn't hang.
}
Also used : StringWriter(java.io.StringWriter) StringReader(java.io.StringReader) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) Test(org.junit.Test) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)

Example 19 with HtmlDocumentBuilder

use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder in project mylyn.docs by eclipse.

the class ConfluenceLanguageTest method testHyperlinkMailtoNoBase.

@Test
public void testHyperlinkMailtoNoBase() {
    StringWriter out = new StringWriter();
    HtmlDocumentBuilder builder = new HtmlDocumentBuilder(out);
    builder.setBase(null);
    parser.setBuilder(builder);
    parser.parse("[test|mailto:foo@bar.com]");
    assertTrue(out.toString().contains("<a href=\"mailto:foo@bar.com\">test</a>"));
}
Also used : StringWriter(java.io.StringWriter) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) Test(org.junit.Test) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)

Example 20 with HtmlDocumentBuilder

use of org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder in project mylyn.docs by eclipse.

the class ConfluenceLanguageTest method testNote3.

@Test
public void testNote3() {
    StringWriter out = new StringWriter();
    HtmlDocumentBuilder builder = new HtmlDocumentBuilder(out);
    builder.setUseInlineStyles(false);
    parser.setBuilder(builder);
    parser.parse("{note}this is a note {note}*bold* text\nfoo\n\nbar");
    String html = out.toString();
    assertTrue(html.contains("<body><div class=\"note\"><p>this is a note </p></div><p><strong>bold</strong> text<br/>foo</p><p>bar</p></body>"));
}
Also used : StringWriter(java.io.StringWriter) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) Test(org.junit.Test) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)

Aggregations

HtmlDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder)58 StringWriter (java.io.StringWriter)46 Test (org.junit.Test)17 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)16 SplittingHtmlDocumentBuilder (org.eclipse.mylyn.wikitext.splitter.SplittingHtmlDocumentBuilder)10 AbstractMarkupGenerationTest (org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)10 File (java.io.File)8 Writer (java.io.Writer)7 StringReader (java.io.StringReader)6 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)6 SplitOutlineItem (org.eclipse.mylyn.wikitext.splitter.SplitOutlineItem)6 OutputStreamWriter (java.io.OutputStreamWriter)5 FileOutputStream (java.io.FileOutputStream)4 IOException (java.io.IOException)4 TextileLanguage (org.eclipse.mylyn.wikitext.textile.TextileLanguage)4 PrintWriter (java.io.PrintWriter)3 LinkAttributes (org.eclipse.mylyn.wikitext.parser.LinkAttributes)3 DefaultSplittingStrategy (org.eclipse.mylyn.wikitext.splitter.DefaultSplittingStrategy)3 SplittingOutlineParser (org.eclipse.mylyn.wikitext.splitter.SplittingOutlineParser)3 Before (org.junit.Before)3