Markdown reader: don't lose parentheses in URLs.
Added tests. This fixes a regression from 1.10.x. Closes #786.
This commit is contained in:
parent
d820eb2c47
commit
db3d4113a2
3 changed files with 22 additions and 4 deletions
|
@ -287,8 +287,7 @@ referenceKey = try $ do
|
|||
referenceTitle :: MarkdownParser String
|
||||
referenceTitle = try $ do
|
||||
skipSpaces >> optional newline >> skipSpaces
|
||||
let parenTit = charsInBalanced '(' ')' litChar
|
||||
quotedTitle '"' <|> quotedTitle '\'' <|> parenTit
|
||||
quotedTitle '"' <|> quotedTitle '\'' <|> charsInBalanced '(' ')' litChar
|
||||
|
||||
-- A link title in quotes
|
||||
quotedTitle :: Char -> MarkdownParser String
|
||||
|
@ -1494,13 +1493,18 @@ reference :: MarkdownParser (F Inlines, String)
|
|||
reference = do notFollowedBy' (string "[^") -- footnote reference
|
||||
withRaw $ trimInlinesF <$> inlinesInBalancedBrackets
|
||||
|
||||
parenthesizedChars :: MarkdownParser [Char]
|
||||
parenthesizedChars = do
|
||||
result <- charsInBalanced '(' ')' litChar
|
||||
return $ '(' : result ++ ")"
|
||||
|
||||
-- source for a link, with optional title
|
||||
source :: MarkdownParser (String, String)
|
||||
source = do
|
||||
char '('
|
||||
skipSpaces
|
||||
let urlChunk = try $ notFollowedBy (oneOf "\"')") >>
|
||||
(charsInBalanced '(' ')' litChar <|> count 1 litChar)
|
||||
(parenthesizedChars <|> count 1 litChar)
|
||||
let sourceURL = (unwords . words . concat) <$> many urlChunk
|
||||
let betweenAngles = try $
|
||||
char '<' >> manyTill litChar (char '>')
|
||||
|
|
|
@ -130,4 +130,8 @@
|
|||
,Para [Link [Str "link"] ("/\252rl","\246\246!")]
|
||||
,Para [Link [Str "http://g\246\246gle.com"] ("http://g\246\246gle.com","")]
|
||||
,Para [Link [Str "me@ex\228mple.com"] ("mailto:me@ex\228mple.com","")]
|
||||
,Para [Link [Str "foobar"] ("/\252rl","\246\246!")]]
|
||||
,Para [Link [Str "foobar"] ("/\252rl","\246\246!")]
|
||||
,Header 2 ("parentheses-in-urls",[],[]) [Str "Parentheses",Space,Str "in",Space,Str "URLs"]
|
||||
,Para [Link [Str "link"] ("/hi(there)","")]
|
||||
,Para [Link [Str "link"] ("/hithere)","")]
|
||||
,Para [Link [Str "linky"] ("hi_(there_(nested))","")]]
|
||||
|
|
|
@ -221,3 +221,13 @@ Empty cells
|
|||
[foobar]
|
||||
|
||||
[foobar]: /ürl "öö!"
|
||||
|
||||
## Parentheses in URLs
|
||||
|
||||
[link](/hi(there))
|
||||
|
||||
[link](/hithere\))
|
||||
|
||||
[linky]
|
||||
|
||||
[linky]: hi_(there_(nested))
|
||||
|
|
Loading…
Reference in a new issue