xoofx / markdig

A fast, powerful, CommonMark compliant, extensible Markdown processor for .NET
BSD 2-Clause "Simplified" License
4.21k stars 444 forks source link

Conversion to HTML does not convert some hyperlinks #792

Closed molinch closed 2 months ago

molinch commented 2 months ago

Thanks for this awesome lib, we use it in several places and found one issue.

Given the following Markdown: Hello\n\nIt is me (after 1 hard line break)\n\n<br>\nAnd again me (after 2 hard lines break)\nNow just below, [a link to Google](https://google.fr/)

The HTML will not contains an tag for the Markdown link. Do you have any idea what could lead to this situation? Maybe you are aware of a workaround we could leverage?

Interestingly having just the following works: Now just below, [a link to Google](https://google.fr/)

MihaZupan commented 2 months ago

If you mix HTML tags (<br>) with markdown, you must make sure to end the HTML block with a blank line.

Consider the following examples that differ in new lines:

"<br>\n[label](https://foo)"
HtmlBlock

"<br>\n\n[label](https://foo)"
HtmlBlock, ParagraphBlock, LinkInline, LiteralInline

"<br> [label](https://foo)"
ParagraphBlock, HtmlInline, LiteralInline, LinkInline, LiteralInline

See https://spec.commonmark.org/0.30/#html-blocks for more details.

molinch commented 2 months ago

Thanks a lot @MihaZupan I had no clue, now it is very clear. KUDOS for writing such a clear and detailed answer. It was extremely helpful.