Search in sources :

Example 36 with HtmlDocumentBuilder

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

the class HtmlSubsetDocumentBuilderTest 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));
    builder.setSupportedSpanTypes(Sets.newHashSet(SpanType.BOLD), Collections.<SpanHtmlElementStrategy>emptyList());
    builder.setSupportedHeadingLevel(3);
    builder.beginDocument();
}
Also used : StringWriter(java.io.StringWriter) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) Before(org.junit.Before)

Example 37 with HtmlDocumentBuilder

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

the class HtmlSubsetLanguageTest method cloneSupported.

@Test
public void cloneSupported() {
    HtmlDocumentHandler documentHandler = new HtmlDocumentHandler() {

        @Override
        public void endDocument(HtmlDocumentBuilder builder, XmlStreamWriter writer) {
        // ignore
        }

        @Override
        public void beginDocument(HtmlDocumentBuilder builder, XmlStreamWriter writer) {
        // ignore
        }
    };
    HtmlSubsetLanguage language = new HtmlSubsetLanguage("Test", documentHandler, 6, Sets.newHashSet(BlockType.PARAGRAPH, BlockType.DIV, BlockType.QUOTE), Sets.newHashSet(SpanType.CITATION, SpanType.EMPHASIS), ImmutableMap.of(SpanType.EMPHASIS, "new-em"), Collections.<SpanHtmlElementStrategy>emptyList(), false, true);
    HtmlSubsetLanguage cloned = language.clone();
    assertEquals(language.getName(), cloned.getName());
    assertEquals(language.getSupportedBlockTypes(), cloned.getSupportedBlockTypes());
    assertEquals(language.getSupportedHeadingLevel(), cloned.getSupportedHeadingLevel());
    assertEquals(language.getSupportedSpanTypes(), cloned.getSupportedSpanTypes());
    assertEquals(language.getTagNameSubstitutions(), cloned.getTagNameSubstitutions());
}
Also used : HtmlDocumentHandler(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentHandler) XmlStreamWriter(org.eclipse.mylyn.wikitext.util.XmlStreamWriter) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) Test(org.junit.Test)

Example 38 with HtmlDocumentBuilder

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

the class MarkdownLanguageTestBase 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 39 with HtmlDocumentBuilder

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

the class MarkdownRoundTripTest method parseMarkdownToHtml.

private String parseMarkdownToHtml(String markupContent) {
    StringWriter htmlWriter = new StringWriter();
    HtmlDocumentBuilder htmlDocumentBuilder = new HtmlDocumentBuilder(htmlWriter);
    htmlDocumentBuilder.setEmitAsDocument(false);
    MarkupParser markupParser = new MarkupParser(language, htmlDocumentBuilder);
    markupParser.parse(markupContent);
    return htmlWriter.toString();
}
Also used : StringWriter(java.io.StringWriter) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Example 40 with HtmlDocumentBuilder

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

the class MarkupToEclipseHelpMojo method createRootBuilder.

protected HtmlDocumentBuilder createRootBuilder(Writer writer, String name, String relativePath) {
    HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer, formatOutput);
    builder.setTitle(title == null ? name : title);
    builder.setEmitDtd(emitDoctype);
    if (emitDoctype && htmlDoctype != null) {
        builder.setHtmlDtd(htmlDoctype);
    }
    builder.setUseInlineStyles(useInlineCssStyles);
    builder.setSuppressBuiltInStyles(suppressBuiltInCssStyles);
    builder.setLinkRel(linkRel);
    builder.setDefaultAbsoluteLinkTarget(defaultAbsoluteLinkTarget);
    builder.setPrependImagePrefix(prependImagePrefix);
    builder.setXhtmlStrict(xhtmlStrict);
    builder.setCopyrightNotice(copyrightNotice);
    builder.setHtmlFilenameFormat(htmlFilenameFormat);
    configureStylesheets(builder, relativePath);
    return builder;
}
Also used : HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) SplittingHtmlDocumentBuilder(org.eclipse.mylyn.wikitext.splitter.SplittingHtmlDocumentBuilder)

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