scrod / nv

Notational Velocity: modeless, mouseless Mac OS X note-taking application
http://notational.net
GNU General Public License v3.0
2.07k stars 404 forks source link

Better URL recognition #178

Open tewe opened 13 years ago

tewe commented 13 years ago

Currently it gets confused by the parentheses in Markdown syntax: https://img.skitch.com/20110308-x9qadnn4xhfet78cuddq8d8dx1.png

It might help to use: http://daringfireball.net/2010/07/improved_regex_for_matching_urls

scrod commented 13 years ago

John Gruber's regular expression was actually the first place I started, and it turned out to make several overlapping match-group comparisons for any example containing actual markdown URL-formatting with parentheses. And these specific matching ambiguities essentially force all mainstream regex engines (Ruby 1.8, PCRE, ICU) to consider a combinatorial explosion of matches, leading to very long hangs. You can see this earlier implementation here: https://github.com/scrod/nv/blob/be24a7f86d36d910330c389a5f0464c70b2f5d92/AttributedPlainText.m#L169

ghost commented 12 years ago

I didn't want to start a new issue, but here's some URLs that don't get auto-linked as expected.