Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marked does not handle links with parentheses #690

Closed
dend opened this issue Nov 23, 2015 · 14 comments · Fixed by #1135
Closed

Marked does not handle links with parentheses #690

dend opened this issue Nov 23, 2015 · 14 comments · Fixed by #1135
Labels
category: links L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue

Comments

@dend
Copy link

dend commented Nov 23, 2015

This is a carbon copy of this bug for VSCode.

Here is an example where the preview engine in VSCode mis-renders links with parentheses:
image3

Looks like a Marked issue - any way to fix it?

@Feder1co5oave
Copy link
Contributor

There's no way to get around this issue. Just replace closing parentheses with '%29'

@dend
Copy link
Author

dend commented Dec 9, 2015

Why not? Out of curiosity, the StackOverflow inline editor, for example, fully supports this scenario.

@Feder1co5oave
Copy link
Contributor

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
Copy link
Author

dend commented Dec 10, 2015

Surely the balanced parentheses case is more common and would cover 99% of the cases here?

@Feder1co5oave
Copy link
Contributor

Feder1co5oave commented 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
Copy link

hingsir commented Feb 17, 2016

@dend I got the same problem

@sn3p
Copy link

sn3p commented Feb 29, 2016

An option that accepts balanced parentheses matching would be nice.
I don't care if it's off/false by default.

facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Oct 3, 2016
Summary:
The markdown parser (Marked) used by the docs doesn't handle links ending with a closing bracket. The result is a broken link in the [Integration With Existing Apps](http://facebook.github.io/react-native/docs/integration-with-existing-apps.html#our-sample-app) guide.

Using HTML makes the parser ignoring these links.

Note: this is a well-known issue of Marked: markedjs/marked#690
Note bis: The fix #9429 didn't solve the problem.
Closes #10225

Differential Revision: D3964341

fbshipit-source-id: 61564d1cbb632fa1f0c71e7c6cbdc0b9a200caa4
@takluyver
Copy link

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
Copy link
Member

#984

@joshbruce joshbruce reopened this Jan 5, 2018
@joshbruce joshbruce added category: links L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue labels Jan 5, 2018
@ax3l
Copy link

ax3l commented 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 :

[Esirkepov](https://dx.doi.org/10.1016/S0010-4655(00)00228-9)

GitHub renders it correctly:

Esirkepov

@joshbruce
Copy link
Member

@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
Copy link

ax3l commented Feb 22, 2018

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:

github_md

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:

lab_md

@ax3l
Copy link

ax3l commented Feb 22, 2018

@joshbruce
Copy link
Member

@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.

@Feder1co5oave Feder1co5oave self-assigned this Feb 22, 2018
@Feder1co5oave Feder1co5oave added this to the 0.4.0 - No known defects milestone Feb 22, 2018
@Feder1co5oave Feder1co5oave removed their assignment Feb 27, 2018
@joshbruce joshbruce removed this from the 0.4.0 - No known defects milestone Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: links L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants