Search in sources :

Example 1 with HtmlLanguage

use of org.eclipse.mylyn.wikitext.html.HtmlLanguage in project mylyn.docs by eclipse.

the class HtmlLanguageTest method cloneSupported.

@Test
public void cloneSupported() {
    HtmlLanguage language = new HtmlLanguage();
    HtmlLanguage cloned = language.clone();
    assertNotNull(cloned);
    assertEquals(language.getName(), cloned.getName());
}
Also used : HtmlLanguage(org.eclipse.mylyn.wikitext.html.HtmlLanguage) Test(org.junit.Test)

Example 2 with HtmlLanguage

use of org.eclipse.mylyn.wikitext.html.HtmlLanguage in project mylyn.docs by eclipse.

the class HtmlLanguageTest method parseCleansHtmlSetOnClone.

@Test
public void parseCleansHtmlSetOnClone() {
    HtmlLanguage htmlLanguage = new HtmlLanguage();
    htmlLanguage.setParseCleansHtml(true);
    assertEquals(htmlLanguage.isParseCleansHtml(), htmlLanguage.clone().isParseCleansHtml());
    htmlLanguage.setParseCleansHtml(false);
    assertEquals(htmlLanguage.isParseCleansHtml(), htmlLanguage.clone().isParseCleansHtml());
}
Also used : HtmlLanguage(org.eclipse.mylyn.wikitext.html.HtmlLanguage) Test(org.junit.Test)

Example 3 with HtmlLanguage

use of org.eclipse.mylyn.wikitext.html.HtmlLanguage in project mylyn.docs by eclipse.

the class HtmlLanguageTest method assertProcessContent.

protected void assertProcessContent(String expectedHtml, String sourceHtml, boolean asDocument, boolean parseCleansHtml) {
    Writer out = new StringWriter();
    HtmlDocumentBuilder builder = new HtmlDocumentBuilder(out);
    HtmlLanguage language = new HtmlLanguage();
    language.setParseCleansHtml(parseCleansHtml);
    MarkupParser markupParser = new MarkupParser(language, builder);
    markupParser.parse(sourceHtml, asDocument);
    assertEquals(expectedHtml, out.toString());
}
Also used : StringWriter(java.io.StringWriter) HtmlLanguage(org.eclipse.mylyn.wikitext.html.HtmlLanguage) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) StringWriter(java.io.StringWriter) Writer(java.io.Writer) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Example 4 with HtmlLanguage

use of org.eclipse.mylyn.wikitext.html.HtmlLanguage in project mylyn.docs by eclipse.

the class HtmlLanguageTest method newDocumentBuilder.

@Test
public void newDocumentBuilder() {
    Writer out = new StringWriter();
    DocumentBuilder builder = new HtmlLanguage().createDocumentBuilder(out);
    assertNotNull(builder);
    assertTrue(builder instanceof HtmlDocumentBuilder);
}
Also used : StringWriter(java.io.StringWriter) DocumentBuilder(org.eclipse.mylyn.wikitext.parser.DocumentBuilder) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) HtmlLanguage(org.eclipse.mylyn.wikitext.html.HtmlLanguage) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) StringWriter(java.io.StringWriter) Writer(java.io.Writer) Test(org.junit.Test)

Example 5 with HtmlLanguage

use of org.eclipse.mylyn.wikitext.html.HtmlLanguage in project mylyn.docs by eclipse.

the class ConfluenceLanguageIntegrationTest method assertHtmlToConfluence.

private void assertHtmlToConfluence(boolean parseAsDocument) {
    HtmlLanguage htmlLanguage = HtmlLanguage.builder().add(BlockType.PARAGRAPH).add(SpanType.BOLD).name("Test").create();
    MarkupParser parser = new MarkupParser(htmlLanguage);
    Writer confluenceOut = new StringWriter();
    DocumentBuilder confuenceBuilder = new ConfluenceLanguage().createDocumentBuilder(confluenceOut);
    parser.setBuilder(confuenceBuilder);
    parser.parse("<html><body>some text <b>bold here</b> more text</body></html>", parseAsDocument);
    assertEquals("some text *bold here* more text\n\n", confluenceOut.toString());
}
Also used : StringWriter(java.io.StringWriter) DocumentBuilder(org.eclipse.mylyn.wikitext.parser.DocumentBuilder) EventDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder) HtmlLanguage(org.eclipse.mylyn.wikitext.html.HtmlLanguage) StringWriter(java.io.StringWriter) Writer(java.io.Writer) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Aggregations

HtmlLanguage (org.eclipse.mylyn.wikitext.html.HtmlLanguage)12 Test (org.junit.Test)9 StringWriter (java.io.StringWriter)6 Writer (java.io.Writer)6 DocumentBuilder (org.eclipse.mylyn.wikitext.parser.DocumentBuilder)5 HtmlDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder)4 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)3 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)2 EventDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder)2 MarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)1