-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Link parsing doesn't correctly match URLs when they include brackets #116
Comments
This also affects images:
Becomes:
When it should become:
|
This is definitely a bug, but a fix is a bit unclear. Skipping balanced pairs of parentheses is easy, but how far ahead should we look? Until EOL? Until a blank line? |
Gruber encountered this problem with the original Markdown library and helping to support others, he basically used a URL matching regexp that handled pairs of brackets in URLs which resolves the vast majority of instances in which it happens:
Note example 6 of the linked demo of that regex. |
Ooh, what a beastie :-) I'll try to take a look if I can plug regexp in the middle of our other parsing and how will that affect the performance. Thanks! |
Links like: ![](http://www.broadgate.co.uk/Content/Upload/DetailImages/Cyclus700(1).jpg)" are not correctly parsed because the closing brace of (1) is seen as the end of the link, which it isn't. Add code that detects opening braces and tries to find a matching closing one. If we are left with an uneven pair, fail the link detections. Add tests from blackfriday issue #116 russross#116
@miekg, can you do a PR to blackfriday with your fix? |
Yeah, I run into this almost daily still, right now I just hand replace parens with |
For a given piece of Markdown:
[disambiguation](http://en.wikipedia.org/wiki/Disambiguation_(disambiguation))
I would expect to see the output:
<p><a href="http://en.wikipedia.org/wiki/Disambiguation_(disambiguation)">disambiguation</a></p>
However blackfriday moves the second
)
outside of the link, thus breaking the URL:<p><a href="http://en.wikipedia.org/wiki/Disambiguation_(disambiguation">disambiguation</a>)</p>
You can recreate this with this example code:
The correct output is generated by most other Markdown parsers, here's Pandoc as the online link makes it the easiest to share:
http://johnmacfarlane.net/pandoc/try/?text=[disambiguation]%28http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FDisambiguation_%28disambiguation%29%29&from=markdown&to=html
Bracketed links are very popular on Wikipedia and a few other top-100 internet sites.
The text was updated successfully, but these errors were encountered: