git.iko.soy/typeable/pandoc
on master help sign in
RST reader: fix anonymous redirects with backticks.

Closes #4598.

commita96c762a10f9b6e97a5660664750ad6e3ef7f5b7 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 26 Apr 2018, 12:10 (9 years ago) parent50da884
2 files changed+18−3
src/Text/Pandoc/Readers/RST.hs+8−3 test/command/4598.md+10
src/Text/Pandoc/Readers/RST.hs+8−3
@@ -1090,10 +1090,15 @@ targetURI :: Monad m => ParserT [Char] st m [Char]
10901090targetURI = do
10911091 skipSpaces
10921092 optional newline
1093− contents <- many1 (try (many spaceChar >> newline >>
1094− many1 spaceChar >> noneOf " \t\n") <|> noneOf "\n")
1093+ contents <- trim <$>
1094+ many1 (satisfy (/='\n')
1095+ <|> try (newline >> many1 spaceChar >> noneOf " \t\n"))
10951096 blanklines
1096− return $ escapeURI $ trim contents
1097+ case reverse contents of
1098+ -- strip backticks
1099+ '_':'`':xs -> return (dropWhile (=='`') (reverse xs) ++ "_")
1100+ '_':_ -> return contents
1101+ _ -> return (escapeURI contents)
10971102
10981103substKey :: PandocMonad m => RSTParser m ()
10991104substKey = try $ do
test/command/4598.mdnew file+10
@@ -0,0 +1,10 @@
1+```
2+% pandoc -f rst
3+`x`__
4+
5+__ `xy`_
6+
7+.. _`xy`: http://xy.org
8+^D
9+<p><a href="http://xy.org">x</a></p>
10+```