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.
This commit is contained in:
John MacFarlane 2014-08-14 10:56:41 -07:00
parent 5524b5286b
commit 8bf39cf6d6
3 changed files with 9 additions and 4 deletions

View file

@ -1635,8 +1635,10 @@ source :: MarkdownParser (String, String)
source = do
char '('
skipSpaces
let urlChunk = try $ notFollowedBy (oneOf "\"')") >>
(parenthesizedChars <|> count 1 litChar)
let urlChunk =
try parenthesizedChars
<|> (notFollowedBy (oneOf " )") >> (count 1 litChar))
<|> try (many1 spaceChar <* notFollowedBy (oneOf "\"')"))
let sourceURL = (unwords . words . concat) <$> many urlChunk
let betweenAngles = try $
char '<' >> manyTill litChar (char '>')

View file

@ -5,9 +5,10 @@
,Plain [RawInline (Format "tex") "\\placeformula "]
,RawBlock (Format "context") "\\startformula\n L_{1} = L_{2}\n \\stopformula"
,RawBlock (Format "context") "\\start[a2]\n\\start[a2]\n\\stop[a2]\n\\stop[a2]"
,Header 2 ("urls-with-spaces",[],[]) [Str "URLs",Space,Str "with",Space,Str "spaces"]
,Header 2 ("urls-with-spaces-and-punctuation",[],[]) [Str "URLs",Space,Str "with",Space,Str "spaces",Space,Str "and",Space,Str "punctuation"]
,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")]
,Para [Link [Str "baz"] ("/foo%20foo",""),Space,Link [Str "bam"] ("/foo%20fee",""),Space,Link [Str "bork"] ("/foo/zee%20zob","title")]
,Para [Link [Str "Ward\8217s",Space,Str "method."] ("http://en.wikipedia.org/wiki/Ward's_method","")]
,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"]
,HorizontalRule
,HorizontalRule

View file

@ -28,7 +28,7 @@
\stop[a2]
\stop[a2]
## URLs with spaces
## URLs with spaces and punctuation
[foo](/bar and baz)
[foo](/bar
@ -42,6 +42,8 @@
[bam]: /foo fee
[bork]: /foo/zee zob (title)
[Ward's method.](http://en.wikipedia.org/wiki/Ward's_method)
## Horizontal rules with spaces at end
* * * * *