eXist-db / exist-markdown

Markdown Parser in XQuery
Other
13 stars 9 forks source link

[BUG] Parsing of `mark` element in "Inline HTML" test #17

Open joewiz opened 2 years ago

joewiz commented 2 years ago

Expected behavior

In inline HTML, inline elements like <mark> should be preserved.

Actual behavior

The elements are dropped from output.

Reproduction steps

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

This test takes this markdown:

A <span style="color: red;">paragraph <span style="color: green;">containing</span></span> some <mark>inline</mark> <code>HTML</code>.

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

<body>
    <p>A <span style="color: red;">paragraph <span style="color: green;">containing</span></span> some <mark>inline</mark> <code>HTML</code>.</p>
</body>

The Commonmark dingus at https://spec.commonmark.org/dingus/ returns this exactly (sans the <body> wrapper, which exist-markdown uses to ensure its results are well-formed, and which users of the library would normally omit from output):

<p>A <span style="color: red;">paragraph <span style="color: green;">containing</span></span> some <mark>inline</mark> <code>HTML</code>.</p>

But it actually returns:

<body>
    <p>A <span style="color: red;">paragraph <span style="color: green;">containing</span></span> some  <code>HTML</code>.</p>
</body>

Note that the <mark>inline</mark> element was dropped from the output and replaced with an extra space character between some and <code>HTML</code>.

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="Inline HTML" class="tests:inline-html">
    <failure message="assertTrue failed." type="failure-error-code-1"/>
    <output>false</output>
</testcase>

Please provide the following