Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Markdown interleaved in HTML blocks is mangled #19

Open
joewiz opened this issue Feb 14, 2022 · 0 comments
Open

[BUG] Markdown interleaved in HTML blocks is mangled #19

joewiz opened this issue Feb 14, 2022 · 0 comments
Labels

Comments

@joewiz
Copy link
Member

joewiz commented Feb 14, 2022

Expected behavior

Markdown interleaved in HTML blocks was expected to work by the author of test.md.

Actual behavior

Markdown interleaved in HTML blocks is mangled

Reproduction steps

See the pending test at https://github.com/eXist-db/exist-markdown/blob/master/test/xqs/test-suite.xqm#L309-L340.

This test takes this markdown:

<div class="row">
    <div class="col-md-6">
        First column in **two column layout**.
        
        Second paragraph.
    </div>
    <div class="col-md-6">
        Second column in two column layout.
    </div>
</div>

With this input, the markdown:parse() function should return:

<body>
    <div class="row">
        <div class="col-md-6">
            <p>First column in <strong>two column layout</strong>.</p>
            <p>Second paragraph.</p>
        </div>
        <div class="col-md-6">
            <p>Second column in two column layout.</p>
        </div>
    </div>
</body>

But it actually returns:

<body>
    <div class="row">
        <body/>
        <div class="col-md-6">
            <body>
                <p>First column in two column layout.</p>
            </body>
        </div>
    </div>
    <p>Second paragraph. <div class="col-md-6"> Second column in two column layout. </div> &lt;/div&gt;</p>
</body>

Note that (1) an empty <body/> element is inserted into the outer div, (2) the "Second paragraph" is ejected from the first inner div, and (3) the second inner div is inserted into the "Second paragraph" <p> element.

Since the parsed markdown doesn't equal the expected output, the test fails (and is marked as pending in the source until a fix is in place):

<testcase name="HTML block containing markdown" class="tests:html-block-containing-markdown">
    <failure message="assertTrue failed." type="failure-error-code-1"/>
    <output>false</output>
</testcase>

Note that the Commonmark dingus at https://spec.commonmark.org/dingus/ also produces mangled output:

<div class="row">
    <div class="col-md-6">
        First column in **two column layout**.
<pre><code>    Second paragraph.
&lt;/div&gt;
&lt;div class=&quot;col-md-6&quot;&gt;
    Second column in two column layout.
&lt;/div&gt;
</code></pre>
</div>

This suggests that a Commonmark-compliant processor may not be expected to handle interleaved HTML blocks and Markdown.

Please provide the following

  • Java Version: n/a
  • exist-db version: 6.1.0-SNAPSHOT
  • exist-markdown version: 1.0.0
  • OS version: n/a
@joewiz joewiz added the bug label Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant