git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Better handle quote characters in inline links.

This was previously failing to be recognized as a link: [Test](http://en.wikipedia.org/wiki/Ward's_method) Closes #1534.

commit8bf39cf6d676ec9ebb8ac0e13b60621ea363d6f3 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 14 Aug 2014, 10:56 (12 years ago) parent5524b52
3 files changed+9−4
src/Text/Pandoc/Readers/Markdown.hs+4−2 tests/markdown-reader-more.native+2−1 tests/markdown-reader-more.txt+3−1
src/Text/Pandoc/Readers/Markdown.hs+4−2
@@ -1635,8 +1635,10 @@ source :: MarkdownParser (String, String)
16351635source = do
16361636 char '('
16371637 skipSpaces
1638− let urlChunk = try $ notFollowedBy (oneOf "\"')") >>
1639− (parenthesizedChars <|> count 1 litChar)
1638+ let urlChunk =
1639+ try parenthesizedChars
1640+ <|> (notFollowedBy (oneOf " )") >> (count 1 litChar))
1641+ <|> try (many1 spaceChar <* notFollowedBy (oneOf "\"')"))
16401642 let sourceURL = (unwords . words . concat) <$> many urlChunk
16411643 let betweenAngles = try $
16421644 char '<' >> manyTill litChar (char '>')
tests/markdown-reader-more.native+2−1
@@ -5,9 +5,10 @@
55,Plain [RawInline (Format "tex") "\\placeformula "]
66,RawBlock (Format "context") "\\startformula\n L_{1} = L_{2}\n \\stopformula"
77,RawBlock (Format "context") "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]"
8−,Header 2 ("urls-with-spaces",[],[]) [Str "URLs",Space,Str "with",Space,Str "spaces"]
8+,Header 2 ("urls-with-spaces-and-punctuation",[],[]) [Str "URLs",Space,Str "with",Space,Str "spaces",Space,Str "and",Space,Str "punctuation"]
99,Para [Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("/bar%20and%20baz",""),Space,Link [Str "foo"] ("bar%20baz","title")]
1010,Para [Link [Str "baz"] ("/foo%20foo",""),Space,Link [Str "bam"] ("/foo%20fee",""),Space,Link [Str "bork"] ("/foo/zee%20zob","title")]
11+,Para [Link [Str "Ward\8217s",Space,Str "method."] ("http://en.wikipedia.org/wiki/Ward's_method","")]
1112,Header 2 ("horizontal-rules-with-spaces-at-end",[],[]) [Str "Horizontal",Space,Str "rules",Space,Str "with",Space,Str "spaces",Space,Str "at",Space,Str "end"]
1213,HorizontalRule
1314,HorizontalRule
tests/markdown-reader-more.txt+3−1
@@ -28,7 +28,7 @@
2828\stop[a2]
2929\stop[a2]
3030
31−## URLs with spaces
31+## URLs with spaces and punctuation
3232
3333[foo](/bar and baz)
3434[foo](/bar
@@ -42,6 +42,8 @@
4242[bam]: /foo fee
4343[bork]: /foo/zee zob (title)
4444
45+[Ward's method.](http://en.wikipedia.org/wiki/Ward's_method)
46+
4547## Horizontal rules with spaces at end
4648
4749* * * * *