From d21a9cd7f80cedb18d97cb92163ae7ec0f3a6237 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 23 Aug 2023 12:37:49 -0700 Subject: Also escape % in URLs. This improves the fix to #9017 in commit 7c4354646b57aa0d505dc955f856b8c3443c8db4 An alternative would be to avoid backslash escaping `#` and `%` in URLs, and instead always add `fragile` to the slide environment. --- src/Text/Pandoc/Writers/LaTeX/Util.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Writers/LaTeX/Util.hs b/src/Text/Pandoc/Writers/LaTeX/Util.hs index f19f5ddd5..79937e1fa 100644 --- a/src/Text/Pandoc/Writers/LaTeX/Util.hs +++ b/src/Text/Pandoc/Writers/LaTeX/Util.hs @@ -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 "\\}" -- cgit v1.2.3