git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Escape strings in \href{..}.
9305114John MacFarlane
src/Text/Pandoc/Writers/LaTeX.hs+2−2
@@ -370,8 +370,8 @@ inlineToLaTeX (Link txt (src, _)) =
370 do modify $ \s -> s{ stUrl = True }
370 do modify $ \s -> s{ stUrl = True }
371 return $ text $ "\\url{" ++ x ++ "}"
371 return $ text $ "\\url{" ++ x ++ "}"
372 _ -> do contents <- inlineListToLaTeX $ deVerb txt
372 _ -> do contents <- inlineListToLaTeX $ deVerb txt
373− return $ text ("\\href{" ++ src ++ "}{") <> contents <>
373+ return $ text ("\\href{" ++ stringToLaTeX src ++ "}{") <>
374− char '}'
374+ contents <> char '}'
375inlineToLaTeX (Image _ (source, _)) = do
375inlineToLaTeX (Image _ (source, _)) = do
376 modify $ \s -> s{ stGraphics = True }
376 modify $ \s -> s{ stGraphics = True }
377 return $ "\\includegraphics" <> braces (text source)
377 return $ "\\includegraphics" <> braces (text source)
tests/writer.latex+5−5
@@ -581,7 +581,7 @@ spaces: a\^{}b c\^{}d, a\ensuremath{\sim}b c\ensuremath{\sim}d.
581`He said, ``I want to go.''\,' Were you alive in the 70's?
581`He said, ``I want to go.''\,' Were you alive in the 70's?
582
582
583Here is some quoted `\verb!code!' and a
583Here is some quoted `\verb!code!' and a
584−``\href{http://example.com/?foo=1&bar=2}{quoted link}''.
584+``\href{http://example.com/?foo=1\&bar=2}{quoted link}''.
585
585
586Some dashes: one---two --- three---four --- five.
586Some dashes: one---two --- three---four --- five.
587
587
@@ -711,7 +711,7 @@ Just a \href{/url/}{URL}.
711
711
712\href{/url/}{URL and title}
712\href{/url/}{URL and title}
713
713
714−\href{/url/with_underscore}{with\_underscore}
714+\href{/url/with\_underscore}{with\_underscore}
715
715
716\href{mailto:nobody@nowhere.net}{Email link}
716\href{mailto:nobody@nowhere.net}{Email link}
717
717
@@ -746,15 +746,15 @@ Foo \href{/url/}{biz}.
746
746
747\subsection{With ampersands}
747\subsection{With ampersands}
748
748
749−Here's a \href{http://example.com/?foo=1&bar=2}{link with an ampersand in the
749+Here's a \href{http://example.com/?foo=1\&bar=2}{link with an ampersand in the
750URL}.
750URL}.
751
751
752Here's a link with an amersand in the link text:
752Here's a link with an amersand in the link text:
753\href{http://att.com/}{AT\&T}.
753\href{http://att.com/}{AT\&T}.
754
754
755−Here's an \href{/script?foo=1&bar=2}{inline link}.
755+Here's an \href{/script?foo=1\&bar=2}{inline link}.
756
756
757−Here's an \href{/script?foo=1&bar=2}{inline link in pointy braces}.
757+Here's an \href{/script?foo=1\&bar=2}{inline link in pointy braces}.
758
758
759\subsection{Autolinks}
759\subsection{Autolinks}
760
760