Also escape % in URLs.

This improves the fix to #9017 in commit
7c4354646b

An alternative would be to avoid backslash escaping `#` and `%`
in URLs, and instead always add `fragile` to the slide environment.
This commit is contained in:
John MacFarlane
2023-08-23 12:37:49 -07:00
parent 7c4354646b
commit d21a9cd7f8
2 changed files with 7 additions and 4 deletions
+4 -1
View File
@@ -94,9 +94,12 @@ stringToLaTeX context zs = do
in case x of
'\\'| isUrl -> emitc '/' -- NB. / works as path sep even on Windows
'#' | isUrl -> emits "\\#" -- see #9014
'%' | isUrl -> emits "\\%" -- see #9014
c | isUrl ->
if c `elem` ['{', '}', '|', '^', '~', '[', ']', '`']
then emits (escapeURIString (const False) [c])
then do
emitc '\\' -- escape the % see #9014
emits (escapeURIString (const False) [c])
else emitc c
'{' -> emits "\\{"
'}' -> emits "\\}"
+3 -3
View File
@@ -8,7 +8,7 @@
^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}
\url{https://example.com/foo\%2Dbar}
\url{https://example.com/foo\%2D\%2Dbar}
\url{https://example.com/foo\%2D\%2Dbar}
```