Markdown: incorrect extra newlines inserted when merging certain html tags

Issue #1099 resolved
Chase Tingley created an issue

Odd testcase attached based on something I encountered.

You can see this by roundtripping the attached md file through the default markdown filter in tikal, which produces this result:

## Here's the testcase

- <a href="https://okapiframework.org">The Okapi Framework</a>
-
   <Link to="https://okapiframework.org">The OkapiFramework</a>
- Another list item containing <b>inline markup</b>

Note the newline on line 4 that has been inserted before <Link>. This is not present in the source. I initially thought this has to do with the fact that <Link> is not in the default HTML subfilter config, so I attached a custom filter/subfilter pair that adds it. This has no effect on the outcome.

The issue seems to be because of a difference in tokenization at the flexmark/`MarkdownParser` level, where the <Link....</Link> content is exposed to the filter as an HTML_BLOCK token type. The equivalent <a ....</a> content is exposed as HTML_INLINE. I am not sure what the reason is for this, or if the bug is in flexmark vs MarkdownParser.

Comments (4)

  1. Log in to comment