@@ -287,8 +287,7 @@ referenceKey = try $ do
287referenceTitle :: MarkdownParser String
287referenceTitle :: MarkdownParser String
288referenceTitle = try $ do
288referenceTitle = try $ do
289 skipSpaces >> optional newline >> skipSpaces
289 skipSpaces >> optional newline >> skipSpaces
290− let parenTit = charsInBalanced '(' ')' litChar
290+ quotedTitle '"' <|> quotedTitle '\'' <|> charsInBalanced '(' ')' litChar
291− quotedTitle '"' <|> quotedTitle '\'' <|> parenTit
293-- A link title in quotes
292-- A link title in quotes
294quotedTitle :: Char -> MarkdownParser String
293quotedTitle :: Char -> MarkdownParser String
@@ -1494,13 +1493,18 @@ reference :: MarkdownParser (F Inlines, String)
1494reference = do notFollowedBy' (string "[^") -- footnote reference
1493reference = do notFollowedBy' (string "[^") -- footnote reference
1495 withRaw $ trimInlinesF <$> inlinesInBalancedBrackets
1494 withRaw $ trimInlinesF <$> inlinesInBalancedBrackets
1496+parenthesizedChars :: MarkdownParser [Char]
1497+parenthesizedChars = do
1498+ result <- charsInBalanced '(' ')' litChar
1499+ return $ '(' : result ++ ")"
1497-- source for a link, with optional title
1501-- source for a link, with optional title
1498source :: MarkdownParser (String, String)
1502source :: MarkdownParser (String, String)
1499source = do
1503source = do
1500 char '('
1504 char '('
1501 skipSpaces
1505 skipSpaces
1502 let urlChunk = try $ notFollowedBy (oneOf "\"')") >>
1506 let urlChunk = try $ notFollowedBy (oneOf "\"')") >>
1503− (charsInBalanced '(' ')' litChar <|> count 1 litChar)
1507+ (parenthesizedChars <|> count 1 litChar)
1504 let sourceURL = (unwords . words . concat) <$> many urlChunk
1508 let sourceURL = (unwords . words . concat) <$> many urlChunk
1505 let betweenAngles = try $
1509 let betweenAngles = try $
1506 char '<' >> manyTill litChar (char '>')
1510 char '<' >> manyTill litChar (char '>')