Search in sources :

Example 11 with Document

use of org.tautua.markdownpapers.ast.Document in project ceylon by eclipse.

the class PlaintextTests method renderAndCompare.

public void renderAndCompare(String mdFile, String txtFile) throws Exception {
    StringWriter sw = new StringWriter();
    try (InputStreamReader stream = new InputStreamReader(PlaintextTests.class.getResourceAsStream(mdFile))) {
        Parser parser = new Parser(stream);
        Document document = parser.parse();
        PlaintextMarkdownVisitor emitter = new PlaintextMarkdownVisitor(new WordWrap(sw));
        document.accept(emitter);
    }
    StringBuilder sb = new StringBuilder();
    try (BufferedReader r = new BufferedReader(new InputStreamReader(PlaintextTests.class.getResourceAsStream(txtFile)))) {
        String line = r.readLine();
        while (line != null) {
            sb.append(line).append("\n");
            line = r.readLine();
        }
    }
    Assert.assertEquals(sb.toString(), sw.toString().replace("\r\n", "\n"));
}
Also used : StringWriter(java.io.StringWriter) InputStreamReader(java.io.InputStreamReader) WordWrap(org.eclipse.ceylon.common.tool.WordWrap) BufferedReader(java.io.BufferedReader) PlaintextMarkdownVisitor(org.eclipse.ceylon.common.tools.help.PlaintextMarkdownVisitor) Document(org.tautua.markdownpapers.ast.Document) Parser(org.tautua.markdownpapers.parser.Parser)

Aggregations

Document (org.tautua.markdownpapers.ast.Document)11 Test (org.junit.Test)4 Node (org.tautua.markdownpapers.ast.Node)4 BufferedReader (java.io.BufferedReader)2 InputStreamReader (java.io.InputStreamReader)2 StringWriter (java.io.StringWriter)2 ArrayList (java.util.ArrayList)2 Section (org.eclipse.ceylon.common.tools.help.Markdown.Section)2 SimpleNode (org.tautua.markdownpapers.ast.SimpleNode)2 Parser (org.tautua.markdownpapers.parser.Parser)2 WordWrap (com.redhat.ceylon.common.tool.WordWrap)1 Section (com.redhat.ceylon.common.tools.help.Markdown.Section)1 PlaintextMarkdownVisitor (com.redhat.ceylon.common.tools.help.PlaintextMarkdownVisitor)1 WordWrap (org.eclipse.ceylon.common.tool.WordWrap)1 PlaintextMarkdownVisitor (org.eclipse.ceylon.common.tools.help.PlaintextMarkdownVisitor)1 DescribedSection (org.eclipse.ceylon.common.tools.help.model.DescribedSection)1 OptionsSection (org.eclipse.ceylon.common.tools.help.model.OptionsSection)1 SummarySection (org.eclipse.ceylon.common.tools.help.model.SummarySection)1 SynopsesSection (org.eclipse.ceylon.common.tools.help.model.SynopsesSection)1 Header (org.tautua.markdownpapers.ast.Header)1