Search in sources :

Example 6 with HtmlLanguage

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

the class ConfluenceLanguageIntegrationTest method assertHtmlToConfluenceColor.

private void assertHtmlToConfluenceColor(String color, String hex) {
    HtmlLanguage htmlLanguage = HtmlLanguage.builder().add(BlockType.PARAGRAPH).add(SpanType.SPAN).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><span style=\"color: " + color + "\"><del>this text here</del></span></body></html>", true);
    assertEquals("{color:" + hex + "}-this text here-{color}\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)

Example 7 with HtmlLanguage

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

the class HtmlLanguageTest method newDocumentBuilderIsFormatting.

@Test
public void newDocumentBuilderIsFormatting() {
    Writer out = new StringWriter();
    DocumentBuilder builder = new HtmlLanguage().createDocumentBuilder(out, true);
    builder.beginDocument();
    builder.beginBlock(BlockType.PARAGRAPH, new Attributes());
    builder.characters("test");
    builder.endBlock();
    builder.endDocument();
    assertEquals(loadResourceContent("newDocumentBuilderIsFormatting.xml"), out.toString());
}
Also used : StringWriter(java.io.StringWriter) DocumentBuilder(org.eclipse.mylyn.wikitext.parser.DocumentBuilder) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) HtmlLanguage(org.eclipse.mylyn.wikitext.html.HtmlLanguage) StringWriter(java.io.StringWriter) Writer(java.io.Writer) Test(org.junit.Test)

Example 8 with HtmlLanguage

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

the class HtmlLanguageTest method isDiscoverable.

@Test
public void isDiscoverable() {
    MarkupLanguage language = ServiceLocator.getInstance().getMarkupLanguage("HTML");
    assertNotNull(language);
    assertTrue(language instanceof HtmlLanguage);
}
Also used : MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) HtmlLanguage(org.eclipse.mylyn.wikitext.html.HtmlLanguage) Test(org.junit.Test)

Example 9 with HtmlLanguage

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

the class HtmlSubsetLanguageTest method parseCleansHtmlSetOnClone.

@Test
public void parseCleansHtmlSetOnClone() {
    HtmlLanguage htmlLanguage = newHtmlSubsetLanguage(BlockType.PARAGRAPH);
    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 10 with HtmlLanguage

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

the class HtmlLanguageTest method parseCleansHtml.

@Test
public void parseCleansHtml() {
    HtmlLanguage htmlLanguage = new HtmlLanguage();
    htmlLanguage.setParseCleansHtml(true);
    assertTrue(htmlLanguage.isParseCleansHtml());
    htmlLanguage.setParseCleansHtml(false);
    assertFalse(htmlLanguage.isParseCleansHtml());
}
Also used : HtmlLanguage(org.eclipse.mylyn.wikitext.html.HtmlLanguage) Test(org.junit.Test)

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