git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Use \nolinkurl in email autolinks.
c24ab14John MacFarlane
src/Text/Pandoc/Writers/LaTeX.hs+9−2
@@ -757,10 +757,17 @@ inlineToLaTeX (Link txt ('#':ident, _)) = do
757 return $ text "\\hyperref" <> brackets (text lab) <> braces contents
757 return $ text "\\hyperref" <> brackets (text lab) <> braces contents
758inlineToLaTeX (Link txt (src, _)) =
758inlineToLaTeX (Link txt (src, _)) =
759 case txt of
759 case txt of
760− [Str x] | x == src -> -- autolink
760+ [Str x] | escapeURI x == src -> -- autolink
761 do modify $ \s -> s{ stUrl = True }
761 do modify $ \s -> s{ stUrl = True }
762− src' <- stringToLaTeX URLString x
762+ src' <- stringToLaTeX URLString src
763 return $ text $ "\\url{" ++ src' ++ "}"
763 return $ text $ "\\url{" ++ src' ++ "}"
764+ [Str x] | "mailto:" `isPrefixOf` src &&
765+ escapeURI x == drop 7 src -> -- email autolink
766+ do modify $ \s -> s{ stUrl = True }
767+ src' <- stringToLaTeX URLString src
768+ contents <- inlineListToLaTeX txt
769+ return $ "\\href" <> braces (text src') <>
770+ braces ("\\nolinkurl" <> braces contents)
764 _ -> do contents <- inlineListToLaTeX txt
771 _ -> do contents <- inlineListToLaTeX txt
765 src' <- stringToLaTeX URLString src
772 src' <- stringToLaTeX URLString src
766 return $ text ("\\href{" ++ src' ++ "}{") <>
773 return $ text ("\\href{" ++ src' ++ "}{") <>
tests/writer.latex+2−1
@@ -888,7 +888,8 @@ With an ampersand: \url{http://example.com/?foo=1\&bar=2}
888 It should.
888 It should.
889\end{itemize}
889\end{itemize}
890
890
891+An e-mail address:
891−An e-mail address: \href{mailto:nobody@nowhere.net}{nobody@nowhere.net}
892+\href{mailto:nobody@nowhere.net}{\nolinkurl{nobody@nowhere.net}}
892
893
893\begin{quote}
894\begin{quote}
894Blockquoted: \url{http://example.com/}
895Blockquoted: \url{http://example.com/}