git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Properly escape strings inside \url{}.
1e2b20fJohn MacFarlane
src/Text/Pandoc/Writers/LaTeX.hs+2−1
@@ -577,7 +577,8 @@ inlineToLaTeX (Link txt (src, _)) =
577 case txt of
577 case txt of
578 [Code _ x] | x == src -> -- autolink
578 [Code _ x] | x == src -> -- autolink
579 do modify $ \s -> s{ stUrl = True }
579 do modify $ \s -> s{ stUrl = True }
580+ src' <- stringToLaTeX True x
580− return $ text $ "\\url{" ++ x ++ "}"
581+ return $ text $ "\\url{" ++ src' ++ "}"
581 _ -> do contents <- inlineListToLaTeX txt
582 _ -> do contents <- inlineListToLaTeX txt
582 src' <- stringToLaTeX True src
583 src' <- stringToLaTeX True src
583 return $ text ("\\href{" ++ src' ++ "}{") <>
584 return $ text ("\\href{" ++ src' ++ "}{") <>
tests/writer.latex+1−1
@@ -834,7 +834,7 @@ Here's an \href{/script?foo=1\&bar=2}{inline link in pointy braces}.
834
834
835\subsection{Autolinks}
835\subsection{Autolinks}
836
836
837−With an ampersand: \url{http://example.com/?foo=1&bar=2}
837+With an ampersand: \url{http://example.com/?foo=1\&bar=2}
838
838
839\begin{itemize}
839\begin{itemize}
840\item
840\item