Package org.tautua.markdownpapers.ast

Examples of org.tautua.markdownpapers.ast.Document


    public void renderAndCompare(String mdFile, String txtFile) throws Exception {
        StringWriter sw = new StringWriter();
        try (InputStreamReader stream = new InputStreamReader(PlaintextTest.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(PlaintextTest.class.getResourceAsStream(txtFile)))){
View Full Code Here


        return sw.toString();
    }
   
    @Test
    public void testSplit() {
        Document doc = Markdown.markdown("Some stuff\n" +
            "\n" +
            "# First `H1`\n" +
            "\n" +
            "A sentence\n" +
            "\n" +
            "## `H2` under first `H1`" +
            "\n" +
                "A sentence\n" +
                "\n" +
                "# Second `H1`\n" +
                "\n" +
                "A sentence\n" +
                "\n" +
                "## `H2` under second `H1`" +
                "\n" +
                "A sentence\n" +
                "\n");
        List<Section> sections = Markdown.extractSections(doc);
        Assert.assertEquals(3, sections.size());
        Section section = sections.get(0);
        Assert.assertNull(section.getHeading());
        Document sectionBody = section.getDoc();
        Assert.assertEquals("<p>Some stuff</p>", html(sectionBody).trim());
       
        section = sections.get(1);
        Assert.assertEquals("<h1> First <code>H1</code></h1>",
                html(section.getHeading()).trim());
View Full Code Here

"<p>A sentence</p>", html(sectionBody).trim());
    }
   
    @Test
    public void testAdjustHeadings() {
        Document doc = Markdown.markdown("Some stuff\n" +
                "\n" +
                "# First `H1`\n" +
                "\n" +
                "A sentence\n" +
                "\n" +
View Full Code Here

        outFile.getParentFile().mkdirs();
        Writer out = new OutputStreamWriter(buildContext.newFileOutputStream(outFile), UTF8);

        Parser parser = new Parser(in);
        TitleSpyHtmlEmitter emitter = new TitleSpyHtmlEmitter(out);
        Document document = parser.parse();
        document.accept(emitter);

        in.close();
        out.close();

        manifest.put(relativeFragmentPath, emitter.getTitle());
View Full Code Here

TOP

Related Classes of org.tautua.markdownpapers.ast.Document

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.