git.iko.soy/typeable/pandoc
on master help sign in
Improved fix to #5340 and added test.
6be8f4eJohn MacFarlane
src/Text/Pandoc/Writers/LaTeX.hs+2−2
@@ -1219,12 +1219,12 @@ inlineToLaTeX (Link _ txt ('#':ident, _)) = do
1219 return $ text "\\protect\\hyperlink" <> braces (text lab) <> braces contents
1219 return $ text "\\protect\\hyperlink" <> braces (text lab) <> braces contents
1220inlineToLaTeX (Link _ txt (src, _)) =
1220inlineToLaTeX (Link _ txt (src, _)) =
1221 case txt of
1221 case txt of
1222− [Str x] | x == unEscapeString src -> -- autolink
1222+ [Str x] | unEscapeString x == unEscapeString src -> -- autolink
1223 do modify $ \s -> s{ stUrl = True }
1223 do modify $ \s -> s{ stUrl = True }
1224 src' <- stringToLaTeX URLString (escapeURI src)
1224 src' <- stringToLaTeX URLString (escapeURI src)
1225 return $ text $ "\\url{" ++ src' ++ "}"
1225 return $ text $ "\\url{" ++ src' ++ "}"
1226 [Str x] | Just rest <- stripPrefix "mailto:" src,
1226 [Str x] | Just rest <- stripPrefix "mailto:" src,
1227− x == unEscapeString rest -> -- email autolink
1227+ unEscapeString x == unEscapeString rest -> -- email autolink
1228 do modify $ \s -> s{ stUrl = True }
1228 do modify $ \s -> s{ stUrl = True }
1229 src' <- stringToLaTeX URLString (escapeURI src)
1229 src' <- stringToLaTeX URLString (escapeURI src)
1230 contents <- inlineListToLaTeX txt
1230 contents <- inlineListToLaTeX txt
test/command/5340.mdnew file+14
@@ -0,0 +1,14 @@
1+```
2+% pandoc -f html -t latex --wrap=preserve
3+<a href="https://example.com/foo-bar">https://example.com/foo-bar</a>
4+<a href="https://example.com/foo--bar">https://example.com/foo--bar</a>
5+<a href="https://example.com/foo%2Dbar">https://example.com/foo-bar</a>
6+<a href="https://example.com/foo%2D%2Dbar">https://example.com/foo--bar</a>
7+<a href="https://example.com/foo%2D%2Dbar">https://example.com/foo%2D%2Dbar</a>
8+^D
9+\url{https://example.com/foo-bar}
10+\url{https://example.com/foo--bar}
11+\url{https://example.com/foo\%2Dbar}
12+\url{https://example.com/foo\%2D\%2Dbar}
13+\url{https://example.com/foo\%2D\%2Dbar}
14+```