镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Marked does not handle links with parentheses #690

Closed

Description

@dend

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?

Activity

  1. Feder1co5oave commented on Dec 9, 2015

    @Feder1co5oave
    Contributor

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

  2. dend commented on Dec 9, 2015

    @dend
    Author

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

  3. Feder1co5oave commented on Dec 10, 2015

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

  4. dend commented on Dec 10, 2015

    @dend
    Author

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

  5. Feder1co5oave commented on Dec 15, 2015

    @Feder1co5oave
    Contributor

    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.

  6. hingsir commented on Feb 17, 2016

    @hingsir

    @dend I got the same problem

  7. sn3p commented on Feb 29, 2016

    @sn3p

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

  8. takluyver commented on Jul 31, 2017

    @takluyver

    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.

  9. joshbruce commented on Dec 25, 2017

    @joshbruce
    Member
  10. added
    L1 - brokenValid usage causes incorrect output OR a crash AND there is no known workaround for the issue
    on Jan 5, 2018
  11. ax3l commented on Feb 21, 2018

    @ax3l

    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

  12. joshbruce commented on Feb 21, 2018

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

  13. ax3l commented on Feb 22, 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.

    @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

  14. joshbruce commented on Feb 22, 2018

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

  15. added this to the milestone on Feb 22, 2018
  16. removed their assignment
    on Feb 27, 2018
  17. removed this from the milestone on Apr 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    L1 - brokenValid usage causes incorrect output OR a crash AND there is no known workaround for the issuecategory: links

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions