Trouble with parentheses in Markdown hyperlinks

Michel Fortin michel.fortin at michelf.ca
Wed Oct 17 20:56:29 EDT 2012


Le 2012-10-17 à 20:50, Andrew Pennebaker <andrew.pennebaker at gmail.com> a écrit :


> How can we improve URL detection in Markdown? I posted a question on Stack

> Overflow and happened to click a URL in my post. To my surprise, it wasn't

> functional, and it took three different, nonintuitive manipulations before

> I achieved a functional URL. Stack Overflow says "not my problem", so I'm

> deferring to Markdown itself.

>

> Here's a sample<https://raw.github.com/gist/3909246/1885a4d509fb555c158208d9bfc319b9f8f95039/urls.md>Markdown

> document on Gist. All but the final hyperlink fail to be

> functional. You can verify this behavior in

> Dingus<http://daringfireball.net/projects/markdown/dingus>. I'd

> paste my sample directly in Gmail, but it would actually fix the URLs and

> obscure the problem.

>

> I believe this is easily fixed by altering the regex responsible for

> parsing [name](url) syntax to be lazy rather than eager.


It's not so simple (it can break other [links](http://michelf.ca)).

PHP Markdown solves this by attempting to match opening and closing parenthesis in the URL (which works except for some extreme cases like <http://en.wikipedia.org/wiki/(>).

Also, you can wrap your URL in <>: [links](<http://michelf.ca>), but I'm not sure it'll work that well in all implementations.

--
Michel Fortin
michel.fortin at michelf.ca
http://michelf.ca/



More information about the Markdown-Discuss mailing list