aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs4
-rw-r--r--test/command/5340.md14
2 files changed, 16 insertions, 2 deletions
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}
+```