xoofx / markdig

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

Failure to parse complex media links #801

Closed kunom closed 1 month ago

kunom commented 1 month ago

See this document here (it is synthetic data, not related to any real person):

Hier ist das Diagramm mit den letzten Werten von Herrn Fritz Müller für Blutdruck und Blutzucker:

![Diagramm](https://quickchart.io/chart?c={type:'line',data:{labels:['Vorgestern','Gestern'],datasets:[{label:'Oberer Blutdruck (mmHg)',data:[155,160],borderColor:'red'},{label:'Unterer Blutdruck (mmHg)',data:[98,100],borderColor:'blue'},{label:'Blutzucker (mmol/l)',data:[11.5,12],borderColor:'green'}]}})            

Markdig fails to parse the link, returning a list of inline literals, even though I have the impression that ![] style links seem to be supported:

image

On the other hand, http://textlint.github.io/markdown-to-ast/example/ does better:

image

xoofx commented 1 month ago

As per the spec here, an URL link can be only:

a nonempty sequence of characters that does not start with <, does not include ASCII control characters or space character, and includes parentheses only if (a) they are backslash-escaped or (b) they are part of a balanced pair of unescaped parentheses. (Implementations may impose limits on parentheses nesting to avoid performance issues, but at least three levels of nesting should be supported.)

And your URLs contains spaces, so I believe that it is most likely the problem.

Check also on babelmark here++) and you can see that it is failing for all CommonMark parsers and many Markdown implementations.