Skip to content

Commit

Permalink
Markdown reader: allow line break between URL and title of link.
Browse files Browse the repository at this point in the history
Closes #10621.
  • Loading branch information
jgm committed Feb 14, 2025
1 parent f5d41a0 commit bf1c17c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Text/Pandoc/Readers/Markdown.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions test/command/10621.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```
% pandoc -f markdown -t html
[test](url
"title")
^D
<p><a href="url" title="title">test</a></p>
```

0 comments on commit bf1c17c

Please sign in to comment.