diff options
| author | John MacFarlane <[email protected]> | 2025-02-14 10:17:26 -0800 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-02-14 10:17:26 -0800 |
| commit | bf1c17c883764c6f4af5716dc208f1b751720853 (patch) | |
| tree | 1050a33f1059e6d5a614c9f6177372091ff51a21 /src | |
| parent | f5d41a0c3f0809f2838dafa22e2404e6010eac7e (diff) | |
Markdown reader: allow line break between URL and title of link.
Closes #10621.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index a0fd682df..d019ee1a5 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1818,25 +1818,25 @@ reference = do guardDisabled Ext_footnotes <|> notFollowedBy' noteMarker withRaw $ trimInlinesF <$> inBalancedBrackets inlines -parenthesizedChars :: PandocMonad m => MarkdownParser m Text -parenthesizedChars = do - result <- charsInBalanced '(' ')' litChar - return $ "(" <> result <> ")" - -- source for a link, with optional title source :: PandocMonad m => MarkdownParser m (Text, Text) source = do char '(' skipSpaces - let urlChunk = - try parenthesizedChars - <|> (notFollowedBy (oneOf " )") >> litChar) - <|> try (many1Char spaceChar <* notFollowedBy (oneOf "\"')")) + let parenthesizedChars = do + result <- charsInBalanced '(' ')' litChar + return $ "(" <> result <> ")" + let linkTitle' = try $ spnl >> linkTitle + let urlChunk = do + notFollowedBy linkTitle' + try parenthesizedChars + <|> (notFollowedBy (oneOf " )") >> litChar) + <|> try (many1Char spaceChar <* notFollowedBy (oneOf "\"')")) let sourceURL = T.unwords . T.words . T.concat <$> many urlChunk let betweenAngles = try $ char '<' >> mconcat <$> (manyTill litChar (char '>')) src <- try betweenAngles <|> try base64DataURI <|> sourceURL - tit <- option "" $ try $ spnl >> linkTitle + tit <- option "" linkTitle' skipSpaces char ')' return (escapeURI $ trimr src, tit) |
