aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2024-12-26 20:06:25 -0800
committerJohn MacFarlane <[email protected]>2024-12-27 19:38:56 -0800
commit9fa4fa3c51d54f3fc67ee105a361ec5d5ae7813e (patch)
tree6837cf2fd637d06660d14f4963b0ce6442998deb /src
parent07105ccbfff3e922d7abe3b85e1d7da740f0ecec (diff)
RST reader: fix handling of underscores.
Fixes a regression in 3.6 that caused problems parsing text with underscores. Closes #10497.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/RST.hs21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index cd3765cb0..a2518c9c0 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -1286,6 +1286,7 @@ substKey = try $ do
anonymousKey :: PandocMonad m => RSTParser m ()
anonymousKey = try $ do
oneOfStrings [".. __:", "__"]
+ skipMany1 spaceChar
src <- targetURI
-- we need to ensure that the keys are ordered by occurrence in
-- the document.
@@ -1462,15 +1463,14 @@ table = gridTable <|> simpleTable False <|> simpleTable True <?> "table"
--
inline :: PandocMonad m => RSTParser m Inlines
-inline = choice [ note -- can start with whitespace, so try before ws
- , link
- , inlineAnchor
- , strong
- , emph
- , code
- , subst
- , interpretedRole
- , inlineContent ] <?> "inline"
+inline =
+ (note -- can start with whitespace, so try before ws
+ <|> do notAfterString >>= guard
+ (link <|> inlineAnchor <|> strong <|> emph)
+ <|> code
+ <|> subst
+ <|> interpretedRole
+ <|> inlineContent) <?> "inline"
-- strings, spaces and other characters that can appear either by
-- themselves or within inline markup
@@ -1730,6 +1730,7 @@ referenceLink :: PandocMonad m => RSTParser m Inlines
referenceLink = try $ do
ref <- (referenceName <|> citationName) <* char '_'
isAnonymous <- (True <$ char '_') <|> pure False
+ eof <|> notFollowedBy alphaNum
let ref' = if isAnonymous
then "_"
else ref
@@ -1797,7 +1798,7 @@ smart :: PandocMonad m => RSTParser m Inlines
smart = smartPunctuation inline
inlineAnchor :: PandocMonad m => RSTParser m Inlines
-inlineAnchor = do
+inlineAnchor = try $ do
char '_'
name <- quotedReferenceName <|> simpleReferenceName
let ident = textToIdentifier mempty name