Trouble with parentheses in Markdown hyperlinks

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

Le 2012-10-17 à 20:50, Andrew Pennebaker <andrew.pennebaker at> 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<>Markdown

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

> functional. You can verify this behavior in

> 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](

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

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

Michel Fortin
michel.fortin at

More information about the Markdown-Discuss mailing list