diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-07-15 16:42:39 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-07-15 16:42:39 -0700 |
commit | c24ab1491808d8be98ab30ba6b3993fa075ca376 (patch) | |
tree | a7dce329e3f32846b249aac79794cbcc1eb7f40c /src/Text/Pandoc/Writers | |
parent | 73b063021749d00701d2196f51b7db925b760f2d (diff) | |
download | pandoc-c24ab1491808d8be98ab30ba6b3993fa075ca376.tar.gz |
LaTeX writer: Use \nolinkurl in email autolinks.
This allows them to be styled using `\urlstyle{tt}`.
Thanks to Ulrike Fischer for the solution.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 5bbe30fc8..0197d5db6 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -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' ++ "}{") <> |