github / markup

Determines which markup library to use to render a content file (e.g. README) on GitHub
MIT License
5.86k stars 3.39k forks source link

Ref-Style Links: Omitting a Space between URL and Alt-Text Breaks all Links #1381

Open tajmone opened 4 years ago

tajmone commented 4 years ago

BUG report: Lack of space separator between URL and alt-text string in a single reference-style link definition breaks multiple (or all) reference-style links in the rendered document.

GitHub's GFM previewer library should be more fault tolerant about this, rendering the document correctly and without breaking all labels.

Problem Description

Yesterday, after pushing a commit on master I realized that the README.md contained some broken referenced-link. The problem was due to a single reference label in which I omitted the separating space between the URL and the alt-text:

Link to [`somefile.sh`][somefile.sh]

[somefile.sh]: ./somefile.sh"View source file"
                             ^ missing space!

The missing space didn't just affect that specific reference link — which was rendered raw in the preview: [`somefile.sh`][somefile.sh] — but every other reference link in the document, which made it quite hard to trace the source of the problem.

Also, the local previewer of my editor (Sublime Text 3 + Markdown Preview) rendered the document without problems, which further made it hard for me to spot the problem in the source file.

Expected Behaviour

Although inserting a separating space in that context is good practice, and omitting it is bad syntax, I believe that GitHub's markdown renderer shouldn't break the document like it did — especially since that single label affected the rendering of all others.

Most markdown previewers are able to parse and render that document without problems, and when you come to think about it the context isn't ambiguous at all since the double quotes character can't possibly be part of an URL; therefore, when the markdown parser encounters a " char while parsing a URL it should interpret it as the beginning of the alt-text string — which is what many markdown rendering libraries and tools actually do in this case.


Bug originally reported on GitHub Community:

https://github.community/t/problem-with-githubs-markdown-rendering-library/128484

github-actions[bot] commented 1 day ago

Stale issue message