@@ -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