Failure to parse complex media links #684

Closed
opened 2026-01-29 14:42:56 +00:00 by claunia · 1 comment
Owner

Originally created by @kunom on GitHub (Jun 7, 2024).

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

Originally created by @kunom on GitHub (Jun 7, 2024). 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](https://github.com/xoofx/markdig/assets/1832956/b598c5da-8947-4301-b7f1-fb2daa8f1fa0) On the other hand, http://textlint.github.io/markdown-to-ast/example/ does better: ![image](https://github.com/xoofx/markdig/assets/1832956/743fb21f-9acc-4f54-b437-3631df6aacc0)
claunia added the wontfix label 2026-01-29 14:42:56 +00:00
Author
Owner

@xoofx commented on GitHub (Jun 7, 2024):

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.

@xoofx commented on GitHub (Jun 7, 2024): As per the spec [here](https://spec.commonmark.org/0.31.2/#link-destination), an URL link can be only: > _a nonempty sequence of characters that does not start with <, does not include [ASCII control characters](https://spec.commonmark.org/0.31.2/#ascii-control-character) or [space](https://spec.commonmark.org/0.31.2/#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](https://babelmark.github.io/?text=Hier+ist+das+Diagramm+mit+den+letzten+Werten+von+Herrn+Fritz+M%C3%BCller+f%C3%BCr+Blutdruck+und+Blutzucker%3A%0A%0A!%5BDiagramm%5D(https%3A%2F%2Fquickchart.io%2Fchart%3Fc%3D%7Btype%3A%27line%27%2Cdata%3A%7Blabels%3A%5B%27Vorgestern%27%2C%27Gestern%27%5D%2Cdatasets%3A%5B%7Blabel%3A%27Oberer+Blutdruck+(mmHg)%27%2Cdata%3A%5B155%2C160%5D%2CborderColor%3A%27red%27%7D%2C%7Blabel%3A%27Unterer+Blutdruck+(mmHg)%27%2Cdata%3A%5B98%2C100%5D%2CborderColor%3A%27blue%27%7D%2C%7Blabel%3A%27Blutzucker+(mmol%2Fl)%27%2Cdata%3A%5B11.5%2C12%5D%2CborderColor%3A%27green%27%7D%5D%7D%7D)++) and you can see that it is failing for all CommonMark parsers and many Markdown implementations.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#684