Search in sources :

Example 31 with HtmlDocumentBuilder

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

the class HtmlSubsetDocumentBuilderXhtmlStrictTest method before.

@Before
public void before() {
    writer = new StringWriter();
    delegate = new HtmlDocumentBuilder(writer);
    delegate.setEmitAsDocument(false);
    builder = new HtmlSubsetDocumentBuilder(delegate);
    builder.setSupportedBlockTypes(Sets.newHashSet(BlockType.PARAGRAPH, BlockType.DIV, BlockType.BULLETED_LIST, BlockType.LIST_ITEM, BlockType.QUOTE, BlockType.PREFORMATTED));
    builder.setSupportedSpanTypes(Sets.newHashSet(SpanType.BOLD), Collections.<SpanHtmlElementStrategy>emptyList());
    builder.setSupportedHeadingLevel(3);
    builder.setXhtmlStrict(true);
    builder.beginDocument();
}
Also used : StringWriter(java.io.StringWriter) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) Before(org.junit.Before)

Example 32 with HtmlDocumentBuilder

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

the class SubstitutionSpanStrategyTest method before.

@Before
public void before() {
    writer = new StringWriter();
    builder = new HtmlDocumentBuilder(writer);
    builder.setEmitAsDocument(false);
}
Also used : StringWriter(java.io.StringWriter) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) Before(org.junit.Before)

Example 33 with HtmlDocumentBuilder

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

the class MarkdownLanguageParagraphBreakingBlocksDisabledTest method parseToHtml.

public String parseToHtml(String markup) {
    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 34 with HtmlDocumentBuilder

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

the class ConfluenceLanguageTest method stackOverflowWithLargeContentOnBug424387.

/**
 * bug 424387
 */
@Test
public void stackOverflowWithLargeContentOnBug424387() throws IOException {
    String content = Resources.toString(ConfluenceLanguageTest.class.getResource("resources/bug424387.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 35 with HtmlDocumentBuilder

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

the class ConfluenceLanguageTest method testNote4.

@Test
public void testNote4() {
    StringWriter out = new StringWriter();
    HtmlDocumentBuilder builder = new HtmlDocumentBuilder(out);
    builder.setUseInlineStyles(false);
    parser.setBuilder(builder);
    parser.parse("abc{note}this is a note {note}*bold* text\nfoo\n\nbar");
    String html = out.toString();
    assertTrue(html.contains("<body><p>abc</p><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