@@ -287,8 +287,7 @@ referenceKey = try $ do
287287referenceTitle :: MarkdownParser String
288288referenceTitle = try $ do
289289 skipSpaces >> optional newline >> skipSpaces
290− let parenTit = charsInBalanced '(' ')' litChar
291− quotedTitle '"' <|> quotedTitle '\'' <|> parenTit
290+ quotedTitle '"' <|> quotedTitle '\'' <|> charsInBalanced '(' ')' litChar
292291
293292-- A link title in quotes
294293quotedTitle :: Char -> MarkdownParser String
@@ -1494,13 +1493,18 @@ reference :: MarkdownParser (F Inlines, String)
14941493reference = do notFollowedBy' (string "[^") -- footnote reference
14951494 withRaw $ trimInlinesF <$> inlinesInBalancedBrackets
14961495
1496+parenthesizedChars :: MarkdownParser [Char]
1497+parenthesizedChars = do
1498+ result <- charsInBalanced '(' ')' litChar
1499+ return $ '(' : result ++ ")"
1500+
14971501-- source for a link, with optional title
14981502source :: MarkdownParser (String, String)
14991503source = do
15001504 char '('
15011505 skipSpaces
15021506 let urlChunk = try $ notFollowedBy (oneOf "\"')") >>
1503− (charsInBalanced '(' ')' litChar <|> count 1 litChar)
1507+ (parenthesizedChars <|> count 1 litChar)
15041508 let sourceURL = (unwords . words . concat) <$> many urlChunk
15051509 let betweenAngles = try $
15061510 char '<' >> manyTill litChar (char '>')