aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2022-07-12 20:11:05 +0200
committerJohn MacFarlane <[email protected]>2022-07-12 20:11:05 +0200
commitc7f5fd240003252fc9cd647015d33ba559ad81e9 (patch)
tree7d85b2ac1291053dc2db9210dd5a041b104f941e /src
parent405a31c3fdfd9171991d37bb6538307b25806b35 (diff)
RST writer: always escape literal backslash.
Previously we didn't escape it when it is word-internal, but that seems wrong. See #8178.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/RST.hs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
index 08e4bfa53..3d1033d72 100644
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -165,7 +165,8 @@ escapeText o = T.pack . escapeString' True o . T.unpack -- This ought to be pars
escapeString' _ _ [] = []
escapeString' firstChar opts (c:cs) =
case c of
- _ | c `elemText` "\\`*_|" &&
+ '\\' -> '\\':c:escapeString' False opts cs
+ _ | c `elemText` "`*_|" &&
(firstChar || null cs) -> '\\':c:escapeString' False opts cs
'\'' | isEnabled Ext_smart opts -> '\\':'\'':escapeString' False opts cs
'"' | isEnabled Ext_smart opts -> '\\':'"':escapeString' False opts cs