LaTeX writer: Use \nolinkurl in email autolinks.

This allows them to be styled using `\urlstyle{tt}`.

Thanks to Ulrike Fischer for the solution.
This commit is contained in:
John MacFarlane 2014-07-15 16:42:39 -07:00
parent 73b0630217
commit c24ab14918
2 changed files with 11 additions and 3 deletions

View file

@ -757,10 +757,17 @@ inlineToLaTeX (Link txt ('#':ident, _)) = do
return $ text "\\hyperref" <> brackets (text lab) <> braces contents
inlineToLaTeX (Link txt (src, _)) =
case txt of
[Str x] | x == src -> -- autolink
[Str x] | escapeURI x == src -> -- autolink
do modify $ \s -> s{ stUrl = True }
src' <- stringToLaTeX URLString x
src' <- stringToLaTeX URLString src
return $ text $ "\\url{" ++ src' ++ "}"
[Str x] | "mailto:" `isPrefixOf` src &&
escapeURI x == drop 7 src -> -- email autolink
do modify $ \s -> s{ stUrl = True }
src' <- stringToLaTeX URLString src
contents <- inlineListToLaTeX txt
return $ "\\href" <> braces (text src') <>
braces ("\\nolinkurl" <> braces contents)
_ -> do contents <- inlineListToLaTeX txt
src' <- stringToLaTeX URLString src
return $ text ("\\href{" ++ src' ++ "}{") <>

View file

@ -888,7 +888,8 @@ With an ampersand: \url{http://example.com/?foo=1\&bar=2}
It should.
\end{itemize}
An e-mail address: \href{mailto:nobody@nowhere.net}{nobody@nowhere.net}
An e-mail address:
\href{mailto:nobody@nowhere.net}{\nolinkurl{nobody@nowhere.net}}
\begin{quote}
Blockquoted: \url{http://example.com/}