diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-04-26 12:10:39 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-04-26 12:23:25 -0700 |
commit | a96c762a10f9b6e97a5660664750ad6e3ef7f5b7 (patch) | |
tree | 3dd2ed3425fface24cbf0e5955eb689f6f28c9ec | |
parent | 50da88446cf28ee8f61ad5a45087628a5e5689ac (diff) | |
download | pandoc-a96c762a10f9b6e97a5660664750ad6e3ef7f5b7.tar.gz |
RST reader: fix anonymous redirects with backticks.
Closes #4598.
-rw-r--r-- | src/Text/Pandoc/Readers/RST.hs | 11 | ||||
-rw-r--r-- | test/command/4598.md | 10 |
2 files changed, 18 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 diff --git a/test/command/4598.md b/test/command/4598.md new file mode 100644 index 000000000..fedfe888a --- /dev/null +++ b/test/command/4598.md @@ -0,0 +1,10 @@ +``` +% pandoc -f rst +`x`__ + +__ `xy`_ + +.. _`xy`: http://xy.org +^D +<p><a href="http://xy.org">x</a></p> +``` |