git.iko.soy/typeable/pandoc
on master help sign in
Improved bare autolink detection.

Previously we disallowed `-` at the end of an autolink, and disallowed the combination `=-`. This commit liberalizes the rules for allowing punctuation in a bare URI. Added test cases. One potential drawback is that you can no longer put a bare URI in em dashes like this this uri---http://example.com---is an example. But in this respect we now match github's treatment of bare URIs. Closes #2299.

commit9cdfd4f6491cbf9e3002e88be8be9ebeb48ba2bb authorJohn MacFarlane <jgm@berkeley.edu> dateTue 14 Jul 2015, 10:20 (11 years ago) parentdce6a73
2 files changed+6−3
src/Text/Pandoc/Parsing.hs+2−3 tests/Tests/Readers/Markdown.hs+4
src/Text/Pandoc/Parsing.hs+2−3
@@ -448,13 +448,12 @@ uri :: Stream [Char] m Char => ParserT [Char] st m (String, String)
448448uri = try $ do
449449 scheme <- uriScheme
450450 char ':'
451− -- We allow punctuation except at the end, since
451+ -- We allow sentence punctuation except at the end, since
452452 -- we don't want the trailing '.' in 'http://google.com.' We want to allow
453453 -- http://en.wikipedia.org/wiki/State_of_emergency_(disambiguation)
454454 -- as a URL, while NOT picking up the closing paren in
455455 -- (http://wikipedia.org). So we include balanced parens in the URL.
456− let isWordChar c = isAlphaNum c || c == '_' || c == '/' || c == '+' ||
457− not (isAscii c)
456+ let isWordChar c = isAlphaNum c || c `elem` "#$%*+/@\\_-"
458457 let wordChar = satisfy isWordChar
459458 let percentEscaped = try $ char '%' >> skipMany1 (satisfy isHexDigit)
460459 let entity = () <$ characterReference
tests/Tests/Readers/Markdown.hs+4
@@ -119,6 +119,10 @@ bareLinkTests =
119119 autolink "http://business.timesonline.co.uk/article/0,,9065-2473189,00.html")
120120 , ("http://www.mail-archive.com/ruby-talk@ruby-lang.org/",
121121 autolink "http://www.mail-archive.com/ruby-talk@ruby-lang.org/")
122+ , ("https://example.org/?anchor=lala-",
123+ autolink "https://example.org/?anchor=lala-")
124+ , ("https://example.org/?anchor=-lala",
125+ autolink "https://example.org/?anchor=-lala")
122126 ]
123127
124128{-