From db3d4113a2c3ef8f36329f08afa02828df79ec75 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 13 Mar 2013 19:18:20 -0700 Subject: Markdown reader: don't lose parentheses in URLs. Added tests. This fixes a regression from 1.10.x. Closes #786. --- src/Text/Pandoc/Readers/Markdown.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 591fcf155..dcab2cea0 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -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 '>') -- cgit v1.2.3