Support up to one level deep of nested parens in urls

(imported from commit 3f314b16a47b5267ddb0d18aa6c5456656895f77)
This commit is contained in:
Leo Franchi
2013-03-29 14:45:22 -04:00
committed by Keegan McAllister
parent 191231ab3d
commit d127d6f19f
2 changed files with 13 additions and 3 deletions

View File

@@ -414,7 +414,10 @@ class Bugdown(markdown.Extension):
#
# This rule must come after the built-in 'link' markdown linkifier to
# avoid errors.
http_link_regex = r'\b(?P<url>https?://[^\s]+?)(?=[^\w/]*(\s|\Z))'
#
# We support up to 1 nested pair of paranthesis in a url
http_link_regex = r'\b(?P<url>https?://(?:(?:[^\s]+\([^\s)]+?\)[^\s]*?)|[^\s]+?))(?=[^\w/]*(\s|\Z))'
md.inlinePatterns.add('http_autolink', HttpLink(http_link_regex), '>link')
# A link starts at a word boundary, and ends at space, punctuation, or end-of-input.