erusev / parsedown

Better Markdown Parser in PHP
https://parsedown.org
MIT License
14.74k stars 1.12k forks source link

Bracketed Links in Bullet List Get Misinterpreted as Reference-Link Definitions #712

Closed neildaniels closed 5 years ago

neildaniels commented 5 years ago

The following Markdown is misinterpreted. It treats the the list item [Example]: Single as a reference-link definition. Something with two or more words (like the "Other" line) are unaffected.

- [Example]: Single
- [Other]: Double Word

[Example]: https://www.example.com
[Other]: https://www.example.com/other
Screen Shot 2019-04-18 at 10 44 34 AM
aidantwoods commented 5 years ago

CommonMark does the same:

https://spec.commonmark.org/dingus/?text=-%20%5BExample%5D%3A%20Single%0A-%20%5BOther%5D%3A%20Double%20Word%0A%0A%5BExample%5D%3A%20https%3A%2F%2Fwww.example.com%0A%5BOther%5D%3A%20https%3A%2F%2Fwww.example.com%2Fother

This because list items are not leaf blocks (they can contain other blocks). The two word variant doesn't satisfy the syntax for a link reference definition and so ends up being rendered how you're expecting. Perhaps try using the full or collapsed syntax for reference links so they don't look like definitions?

neildaniels commented 5 years ago

Thanks for the workaround.

neildaniels commented 5 years ago

TBH, this seems like a bug to me. Is this not going to be fixed?

aidantwoods commented 5 years ago

Spec bugs go in commonmark/commonmark-spec if you wanted to propose a way of fixing it :)