Search in sources :

Example 51 with MarkupParser

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

the class DitaTopicDocumentBuilderTest method testNoFormatting.

public void testNoFormatting() {
    parser = new MarkupParser();
    parser.setMarkupLanguage(new TextileLanguage());
    out = new StringWriter();
    DefaultXmlStreamWriter xmlStreamWriter = new DefaultXmlStreamWriter(out);
    builder = new DitaTopicDocumentBuilder(xmlStreamWriter, false);
    parser.setBuilder(builder);
    parser.parse("h1. Title1\n\nsome content in a para");
    xmlStreamWriter.close();
    String dita = out.toString();
    assertTrue(dita.contains("<topic id=\"Title1\"><title>Title1</title><body><p>some content in a para</p></body></topic>"));
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) StringWriter(java.io.StringWriter) DitaTopicDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.DitaTopicDocumentBuilder) DefaultXmlStreamWriter(org.eclipse.mylyn.wikitext.util.DefaultXmlStreamWriter) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Example 52 with MarkupParser

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

the class DitaTopicDocumentBuilderTest method setUp.

@Override
public void setUp() {
    parser = new MarkupParser();
    parser.setMarkupLanguage(new TextileLanguage());
    out = new StringWriter();
    builder = new DitaTopicDocumentBuilder(out);
    parser.setBuilder(builder);
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) StringWriter(java.io.StringWriter) DitaTopicDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.DitaTopicDocumentBuilder) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Example 53 with MarkupParser

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

the class DocBookDocumentBuilderIntegrationTest method setUp.

@Override
public void setUp() {
    parser = new MarkupParser();
    parser.setMarkupLanguage(new TextileLanguage());
    out = new StringWriter();
    builder = new DocBookDocumentBuilder(out);
    parser.setBuilder(builder);
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) StringWriter(java.io.StringWriter) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Example 54 with MarkupParser

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

the class AbstractSaxParserTest method performTest.

protected void performTest(String html, String expectedResult) throws IOException, SAXException {
    parser.parse(sourceForHtml(html), builder, true);
    String generatedMarkup = out.toString();
    assertEquals(expectedResult, generatedMarkup);
    MarkupParser markupParser = new MarkupParser(new TextileLanguage());
    StringWriter out = new StringWriter();
    HtmlDocumentBuilder htmlBuilder = new HtmlDocumentBuilder(out);
    htmlBuilder.setEmitAsDocument(false);
    markupParser.setBuilder(htmlBuilder);
    markupParser.parse(generatedMarkup);
}
Also used : TextileLanguage(org.eclipse.mylyn.wikitext.textile.TextileLanguage) StringWriter(java.io.StringWriter) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Example 55 with MarkupParser

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

the class TextileLanguageTest method testBug50XHTMLCompliance.

@Test
public void testBug50XHTMLCompliance() throws Exception {
    StringWriter writer = new StringWriter();
    MarkupParser parser = new MarkupParser(new TextileLanguage());
    final HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer);
    builder.setXhtmlStrict(true);
    builder.setEmitDtd(true);
    builder.setHtmlDtd("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
    parser.setBuilder(builder);
    parser.parse("!<image.png!:http://foo.bar");
    String html = writer.toString();
    assertTrue(html.contains("<a href=\"http://foo.bar\"><img style=\"border-width: 0px;text-align: left;\" alt=\"\" src=\"image.png\"/></a>"));
}
Also used : StringWriter(java.io.StringWriter) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser) Test(org.junit.Test) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)

Aggregations

MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)55 StringWriter (java.io.StringWriter)24 HtmlDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder)17 Writer (java.io.Writer)13 Test (org.junit.Test)10 File (java.io.File)8 MarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)8 TextileLanguage (org.eclipse.mylyn.wikitext.textile.TextileLanguage)8 OutputStreamWriter (java.io.OutputStreamWriter)7 FileOutputStream (java.io.FileOutputStream)6 BufferedOutputStream (java.io.BufferedOutputStream)5 IOException (java.io.IOException)5 BuildException (org.apache.tools.ant.BuildException)5 IFile (org.eclipse.core.resources.IFile)4 EventDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder)4 PrintWriter (java.io.PrintWriter)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HtmlLanguage (org.eclipse.mylyn.wikitext.html.HtmlLanguage)3 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)3