markdown-to-jsx icon indicating copy to clipboard operation
markdown-to-jsx copied to clipboard

Parser adding an extra line

Open renerbaffa opened this issue 3 years ago • 3 comments

Hello.

I came across an interesting behavior when playing around with Markdown. Looks like Markdown is breaking my string in a wrong way and it is breaking my the text in an extra unnecessary line.

Using the following string, I got the outcome as displayed by the image above:

'<p style="text-align: left;"><b>The</b> most popular lib</p>'
Screenshot 2020-11-19 at 23 03 24

On the other hand, when I add any content that is not an HTML tag as first child of the <p>, the break line does not happen:

'<p style="text-align: left;">a<b>The</b> most popular lib</p>'
Screenshot 2020-11-19 at 23 03 30

You can play with this example in this codesandbox: https://codesandbox.io/s/html-react-parser-forked-xocqu

It looks like when the content of the first <p> tag is another HTML tag, the parser is breaking the following content to another line. Is this the expected behavior or is it a bug?

renerbaffa avatar Nov 19 '20 22:11 renerbaffa

Hmm, that does seem like a bug. The "b" tag should be detected as an inline HTML tag and processed accordingly.

quantizor avatar Nov 23 '20 19:11 quantizor

Hello,

Just dealing with the same issue but with a custom override this time. Is this going to be fixed at any time soon?

gceico avatar Sep 21 '21 05:09 gceico

I seem to be running into a similar issue with anchor tags. I was able to work around it using forceInline but I don't think that's a solution I can use across the board unfortunately (since we do want breaks for stuff like headers).

rmjohnson avatar Feb 01 '22 21:02 rmjohnson