quantizor / markdown-to-jsx

🏭 The most lightweight, customizable React markdown component.
https://markdown-to-jsx.quantizor.dev/
MIT License
2.03k stars 174 forks source link

Inline HTML breaks subsequent markdown links in same line #308

Open ghost opened 4 years ago

ghost commented 4 years ago

In this paragraph of markdown, the second link isn't parsed by markdown-to-jsx:

Evidence-wise, cognitive restructuring is a component of cognitive-behavioral therapy, which is a strongly supported treatment for a variety of problems<a href="#hofmann2012efficacy"><sup>[1]</sup></a>. Since there seems to be less research on the technique as a standalone therapy, it's likely best used together with behavioral methods like [behavioral activation](/behavioral-activation).

Is that expected behavior?

schalterDev commented 5 months ago

Pasting your example in https://markdown-to-jsx.quantizor.dev/ works like expected.

This example is not working like expected:

<a href="/test">2</a> test [link](/link)
more

This example is working like expected:

a <a href="/test">2</a> test [link](/link)
more

Update: After debugging the examples I found the following problem:

In the working example a paragraph is parsed and inside this paragraph the html-block. The markdown-link is parsed correctly as inline (part of pragraph)

In the not working example there is no paragraph. The html-block is checked before the paragraph (higher priority). After the html-block is parsed no paragraph is detected, because it is not the beginning of a line. The markdown-link is not parsed because it is not inline (part of paragraph) but links have to be inline