You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Marked does not handle links with parentheses #690
Because that would require regexes that count matching opening and closing brackets. And even that is not correct, because URLs are not guaranteed to have balanced brackets in the first place.
Please consider that this behaviour would also break every existing link with escaped closing parens (and unescaped opening ones). IMO the best solution is to use references like suggested in the linked issue.
For reference, the CommonMark spec says that one level of balanced parentheses are allowed in link URLs without being escaped. If there are nested parentheses, or if they're unbalanced, they need to be escaped.
I think this is doable with a regex, but I wouldn't want to be the one writing such a regex.
@ax3l: I’m not sure the example of GitHub doing it properly is actually doing so, I can see the number from the URL after the link text.
Having said that, if it were rendering it probably, I would be curious to know if it’s the GitHub markdown processor doing it, or a post-process of some kind.
We see the issue with Wikipedia URLs as well. Alternatively, one could also hardcode the HTML link, if the output destination is known.
I’m not sure the example of GitHub doing it properly is actually doing so, I can see the number from the URL after the link text.
@joshbruce The GitHub you see is rendered improperly? This is what I see:
I guess it's a tricky regex that balances the brackets.
Interestingly, the downstream Jupyter .md syntax highlighting get's it right (see red parts on the left), only the preview (right, markedjs) has the glitch:
@ax3l: It's what I see now, but wasn't what I was seeing. First time I saw:
Esirkepov00228-9)
So, we'll see what we can do. We're focusing on hitting the CommonMark and GFM specs right now; so, not sure when this will become a priority, if it does. Just to keep you aware of where we are.
Activity
Feder1co5oave commentedon Dec 9, 2015
There's no way to get around this issue. Just replace closing parentheses with '%29'
dend commentedon Dec 9, 2015
Why not? Out of curiosity, the StackOverflow inline editor, for example, fully supports this scenario.
Feder1co5oave commentedon Dec 10, 2015
Because that would require regexes that count matching opening and closing brackets. And even that is not correct, because URLs are not guaranteed to have balanced brackets in the first place.
dend commentedon Dec 10, 2015
Surely the balanced parentheses case is more common and would cover 99% of the cases here?
Feder1co5oave commentedon Dec 15, 2015
Please consider that this behaviour would also break every existing link with escaped closing parens (and unescaped opening ones).
IMO the best solution is to use references like suggested in the linked issue.
hingsir commentedon Feb 17, 2016
@dend I got the same problem
sn3p commentedon Feb 29, 2016
An option that accepts balanced parentheses matching would be nice.
I don't care if it's off/false by default.
Use HTML for links including closing bracket
takluyver commentedon Jul 31, 2017
For reference, the CommonMark spec says that one level of balanced parentheses are allowed in link URLs without being escaped. If there are nested parentheses, or if they're unbalanced, they need to be escaped.
I think this is doable with a regex, but I wouldn't want to be the one writing such a regex.
joshbruce commentedon Dec 25, 2017
#984
ax3l commentedon Feb 21, 2018
Downstream, Jupyter notebooks and Jupyter lab are facing the same issue, e.g. with links to weird DOIs such as
DOI:10.1016/S0010-4655(00)00228-9:GitHub renders it correctly:
Esirkepov
joshbruce commentedon Feb 21, 2018
@ax3l: I’m not sure the example of GitHub doing it properly is actually doing so, I can see the number from the URL after the link text.
Having said that, if it were rendering it probably, I would be curious to know if it’s the GitHub markdown processor doing it, or a post-process of some kind.
We see the issue with Wikipedia URLs as well. Alternatively, one could also hardcode the HTML link, if the output destination is known.
ax3l commentedon Feb 22, 2018
@joshbruce The GitHub you see is rendered improperly? This is what I see:
I guess it's a tricky regex that balances the brackets.
Interestingly, the downstream Jupyter
.mdsyntax highlighting get's it right (see red parts on the left), only the preview (right, markedjs) has the glitch:ax3l commentedon Feb 22, 2018
This seems to be the regex used in pygments, maybe it helps:
https://bitbucket.org/birkenfeld/pygments-main/src/7941677dc77d4f2bf0bbd6140ade85a9454b8b80/pygments/lexers/markup.py?at=default&fileviewer=file-view-default#markup.py-585
joshbruce commentedon Feb 22, 2018
@ax3l: It's what I see now, but wasn't what I was seeing. First time I saw:
So, we'll see what we can do. We're focusing on hitting the CommonMark and GFM specs right now; so, not sure when this will become a priority, if it does. Just to keep you aware of where we are.