From 6be8f4e953b6ba9a7af1b707ef3902f8a5b7b8e2 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Mon, 18 Mar 2019 16:53:36 -0700 Subject: [PATCH] Improved fix to #5340 and added test. --- src/Text/Pandoc/Writers/LaTeX.hs | 4 ++-- test/command/5340.md | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 test/command/5340.md diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index fd1606c41..bee68bd53 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -1219,12 +1219,12 @@ inlineToLaTeX (Link _ txt ('#':ident, _)) = do return $ text "\\protect\\hyperlink" <> braces (text lab) <> braces contents inlineToLaTeX (Link _ txt (src, _)) = case txt of - [Str x] | x == unEscapeString src -> -- autolink + [Str x] | unEscapeString x == unEscapeString src -> -- autolink do modify $ \s -> s{ stUrl = True } src' <- stringToLaTeX URLString (escapeURI src) return $ text $ "\\url{" ++ src' ++ "}" [Str x] | Just rest <- stripPrefix "mailto:" src, - x == unEscapeString rest -> -- email autolink + unEscapeString x == unEscapeString rest -> -- email autolink do modify $ \s -> s{ stUrl = True } src' <- stringToLaTeX URLString (escapeURI src) contents <- inlineListToLaTeX txt diff --git a/test/command/5340.md b/test/command/5340.md new file mode 100644 index 000000000..416f0bd6b --- /dev/null +++ b/test/command/5340.md @@ -0,0 +1,14 @@ +``` +% pandoc -f html -t latex --wrap=preserve +<a href="https://example.com/foo-bar">https://example.com/foo-bar</a> +<a href="https://example.com/foo--bar">https://example.com/foo--bar</a> +<a href="https://example.com/foo%2Dbar">https://example.com/foo-bar</a> +<a href="https://example.com/foo%2D%2Dbar">https://example.com/foo--bar</a> +<a href="https://example.com/foo%2D%2Dbar">https://example.com/foo%2D%2Dbar</a> +^D +\url{https://example.com/foo-bar} +\url{https://example.com/foo--bar} +\url{https://example.com/foo\%2Dbar} +\url{https://example.com/foo\%2D\%2Dbar} +\url{https://example.com/foo\%2D\%2Dbar} +```