-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Autolinking - URL surrounded by parentheses #266
Comments
@joemunriq Input: https://www.something.com/1234 Once parsed it becomes: <a href="https://www.something.com/1234">https://www.something.com/1234</a> Input: Follow this [link] to learn more.
[link]: https://www.something.com/1234 Once parsed it becomes: <a href="https://www.something.com/1234">link</a> Input: [link](https://www.something.com/1234) Once parsed it becomes: <a href="https://www.something.com/1234">link</a> Input: ( https://www.something.com/1234 ) Once parsed it becomes: ( <a href="https://www.something.com/1234">https://www.something.com/1234</a> ) |
@wifiextender Thank you for the info... but I'm calling out one specific buggy behavior using Showdown's GFM auto-linking feature, which automatically creates a link when it identifies a URL (without using Markdown's link syntax). If the URL is contained within parens (without spaces), it will include the closing paren as part of the anchor's HREF. |
It looks like GitHub and RedCarpet (the MD parser that GitHub uses) handles this case specifically. It looks for enclosing parens: Can we get these same rules applied to Showdown? Thanks! |
This is a tricky situation because parenthesis are allowed in urls and there can be situations where the rules used by RedCarpet will wrongly exclude the parentehsis from the url. For instance: The url is So this: (http://www.example.com/a/link/that/ends/in/parenthesis) is a link with parentehsis) gets converted into this: (http://www.example.com/a/link/that/ends/in/parenthesis) is a link with parentehsis) <p>(<a href="http://www.example.com/a/link/that/ends/in/parenthesis">http://www.example.com/a/link/that/ends/parenthesis</a>) is a link with parentehsis)</p> which is wrong. Sure, this is an edge case, and it's highly unlikely that an URL will end in a single unpaired parenthesis but... |
on the other hand, it's really easy to workaround this issue: (<https://www.something.com/1234>) |
Regardless, since we have a "GitHub markdown flavour", that tries to follow github rules, I will create an option that implements the rules of github regarding parentehsis in autolinks. This option will be disabled by default, and you would need to explicitely enable it. |
This was added as a new option called |
Input:
(https://www.something.com/1234)
Results in:
(<a href="https://www.something.com/1234)">https://www.something.com/1234)</a>
Note that the trailing paren is included in the target URL.
The text was updated successfully, but these errors were encountered: