aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-04-26 12:10:39 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-04-26 12:23:25 -0700
commita96c762a10f9b6e97a5660664750ad6e3ef7f5b7 (patch)
tree3dd2ed3425fface24cbf0e5955eb689f6f28c9ec /src
parent50da88446cf28ee8f61ad5a45087628a5e5689ac (diff)
downloadpandoc-a96c762a10f9b6e97a5660664750ad6e3ef7f5b7.tar.gz
RST reader: fix anonymous redirects with backticks.
Closes #4598.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/RST.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs
index 1577908a3..71a38cf82 100644
--- a/src/Text/Pandoc/Readers/RST.hs
+++ b/src/Text/Pandoc/Readers/RST.hs
@@ -1090,10 +1090,15 @@ targetURI :: Monad m => ParserT [Char] st m [Char]
targetURI = do
skipSpaces
optional newline
- contents <- many1 (try (many spaceChar >> newline >>
- many1 spaceChar >> noneOf " \t\n") <|> noneOf "\n")
+ contents <- trim <$>
+ many1 (satisfy (/='\n')
+ <|> try (newline >> many1 spaceChar >> noneOf " \t\n"))
blanklines
- return $ escapeURI $ trim contents
+ case reverse contents of
+ -- strip backticks
+ '_':'`':xs -> return (dropWhile (=='`') (reverse xs) ++ "_")
+ '_':_ -> return contents
+ _ -> return (escapeURI contents)
substKey :: PandocMonad m => RSTParser m ()
substKey = try $ do