git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Escape strings in \href{..}.

Previously strings weren't escaped, so %5D would be interpreted as a LaTeX comment!

commit9305114b9ff5a6b742e9e5949e442c188a2f242a authorJohn MacFarlane <jgm@berkeley.edu> dateFri 14 Jan 2011, 18:59 (16 years ago) parent5131589
2 files changed+7−7
src/Text/Pandoc/Writers/LaTeX.hs+2−2 tests/writer.latex+5−5
src/Text/Pandoc/Writers/LaTeX.hs+2−2
@@ -370,8 +370,8 @@ inlineToLaTeX (Link txt (src, _)) =
370370 do modify $ \s -> s{ stUrl = True }
371371 return $ text $ "\\url{" ++ x ++ "}"
372372 _ -> do contents <- inlineListToLaTeX $ deVerb txt
373− return $ text ("\\href{" ++ src ++ "}{") <> contents <>
374− char '}'
373+ return $ text ("\\href{" ++ stringToLaTeX src ++ "}{") <>
374+ contents <> char '}'
375375inlineToLaTeX (Image _ (source, _)) = do
376376 modify $ \s -> s{ stGraphics = True }
377377 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.
581581`He said, ``I want to go.''\,' Were you alive in the 70's?
582582
583583Here 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}''.
585585
586586Some dashes: one---two --- three---four --- five.
587587
@@ -711,7 +711,7 @@ Just a \href{/url/}{URL}.
711711
712712\href{/url/}{URL and title}
713713
714−\href{/url/with_underscore}{with\_underscore}
714+\href{/url/with\_underscore}{with\_underscore}
715715
716716\href{mailto:nobody@nowhere.net}{Email link}
717717
@@ -746,15 +746,15 @@ Foo \href{/url/}{biz}.
746746
747747\subsection{With ampersands}
748748
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
750750URL}.
751751
752752Here's a link with an amersand in the link text:
753753\href{http://att.com/}{AT\&T}.
754754
755−Here's an \href{/script?foo=1&bar=2}{inline link}.
755+Here's an \href{/script?foo=1\&bar=2}{inline link}.
756756
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}.
758758
759759\subsection{Autolinks}
760760