LaTeX writer: Escape strings in \href{..}.

Previously strings weren't escaped, so %5D would be interpreted
as a LaTeX comment!
This commit is contained in:
John MacFarlane 2011-01-14 18:59:50 -08:00
parent 5131589be0
commit 9305114b9f
2 changed files with 7 additions and 7 deletions

View file

@ -370,8 +370,8 @@ inlineToLaTeX (Link txt (src, _)) =
do modify $ \s -> s{ stUrl = True } do modify $ \s -> s{ stUrl = True }
return $ text $ "\\url{" ++ x ++ "}" return $ text $ "\\url{" ++ x ++ "}"
_ -> do contents <- inlineListToLaTeX $ deVerb txt _ -> do contents <- inlineListToLaTeX $ deVerb txt
return $ text ("\\href{" ++ src ++ "}{") <> contents <> return $ text ("\\href{" ++ stringToLaTeX src ++ "}{") <>
char '}' contents <> char '}'
inlineToLaTeX (Image _ (source, _)) = do inlineToLaTeX (Image _ (source, _)) = do
modify $ \s -> s{ stGraphics = True } modify $ \s -> s{ stGraphics = True }
return $ "\\includegraphics" <> braces (text source) return $ "\\includegraphics" <> braces (text source)

View file

@ -581,7 +581,7 @@ spaces: a\^{}b c\^{}d, a\ensuremath{\sim}b c\ensuremath{\sim}d.
`He said, ``I want to go.''\,' Were you alive in the 70's? `He said, ``I want to go.''\,' Were you alive in the 70's?
Here is some quoted `\verb!code!' and a Here is some quoted `\verb!code!' and a
``\href{http://example.com/?foo=1&bar=2}{quoted link}''. ``\href{http://example.com/?foo=1\&bar=2}{quoted link}''.
Some dashes: one---two --- three---four --- five. Some dashes: one---two --- three---four --- five.
@ -711,7 +711,7 @@ Just a \href{/url/}{URL}.
\href{/url/}{URL and title} \href{/url/}{URL and title}
\href{/url/with_underscore}{with\_underscore} \href{/url/with\_underscore}{with\_underscore}
\href{mailto:nobody@nowhere.net}{Email link} \href{mailto:nobody@nowhere.net}{Email link}
@ -746,15 +746,15 @@ Foo \href{/url/}{biz}.
\subsection{With ampersands} \subsection{With ampersands}
Here's a \href{http://example.com/?foo=1&bar=2}{link with an ampersand in the Here's a \href{http://example.com/?foo=1\&bar=2}{link with an ampersand in the
URL}. URL}.
Here's a link with an amersand in the link text: Here's a link with an amersand in the link text:
\href{http://att.com/}{AT\&T}. \href{http://att.com/}{AT\&T}.
Here's an \href{/script?foo=1&bar=2}{inline link}. Here's an \href{/script?foo=1\&bar=2}{inline link}.
Here's an \href{/script?foo=1&bar=2}{inline link in pointy braces}. Here's an \href{/script?foo=1\&bar=2}{inline link in pointy braces}.
\subsection{Autolinks} \subsection{Autolinks}