diff options
| -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> +``` | 
