Blank lines inserted and deleted to/from Markdown documents with table tags in the round trip test

Issue #664 new
Kuro Kurosaka created an issue

Github flavored markdown allows use of the HTML <table> element as part of the markdown file. When a test is added to MarkdownWriterTest.java that uses a Markdown file with a <table> element, it is observed that some blank lines disappear while a new blank line is added at the end of the file. To reproduce, copy the attached html-table.md to okapi/filters/markdown/src/test/resources/net/sf/okapi/filters/markdown, and add the following unit test case to okapi/filters/markdown/src/test/java/net/sf/okapi/filters/markdown/:

    @Test //TODO: Remove me
    public void testHtmlTable() throws Exception {
    testRoundTrip("html-table.md");
    }

then, in okapi/filters/markdown, run:

mvn clean test

Comments (2)

  1. Kuro Kurosaka reporter

    In MarkdownParser.java, newlines are added twice for each Paragraph. This might be contributing to the extra newlines.

        private NodeVisitor visitor = new NodeVisitor(
    
            /* Core nodes */
    
            new VisitHandler<>(AutoLink.class, new Visitor<AutoLink>() {
            ...
            }),
            ...
            new VisitHandler<>(Paragraph.class, new Visitor<Paragraph>() {
                @Override public void visit(Paragraph node) {
                    visitor.visitChildren(node);
                    addBlockNewlines(node);
                }
            }),
           ...);
        ...
        private void addBlockNewlines(Node node) {
            addToQueue(newline, false, SOFT_LINE_BREAK, node);
            addToQueue(newline, false, SOFT_LINE_BREAK, node);
        }
    
  2. Log in to comment