git.iko.soy/typeable/pandoc
on master help sign in
Roff reader: properly handle unknown backslash escapes.
3305a01John MacFarlane
src/Text/Pandoc/Readers/Roff.hs+4−1
@@ -284,7 +284,10 @@ escapeNormal = do
284 CopyMode -> char '\\'
284 CopyMode -> char '\\'
285 NormalMode -> return '\\'
285 NormalMode -> return '\\'
286 return [RoffStr "\\"]
286 return [RoffStr "\\"]
287− _ -> fail $ "Unknown escape character \\" ++ [c]
287+ _ -> return [RoffStr [c]]
288+ -- man 7 groff: "If a backslash is followed by a character that
289+ -- does not constitute a defined escape sequence, the backslash
290+ -- is silently ignored and the character maps to itself."
288
291
289escIgnore :: PandocMonad m
292escIgnore :: PandocMonad m
290 => Char
293 => Char
test/Tests/Readers/Man.hs+2
@@ -81,6 +81,8 @@ tests = [
81 "\\[u2020]" =?> (para $ text "†")
81 "\\[u2020]" =?> (para $ text "†")
82 , "unicode escapes (combined)" =:
82 , "unicode escapes (combined)" =:
83 "\\[u0075_u0301]" =?> (para $ text "\250")
83 "\\[u0075_u0301]" =?> (para $ text "\250")
84+ , "unknown escape (#5034)" =:
85+ "\\9" =?> (para $ text "9")
84 ],
86 ],
85 testGroup "Lists" [
87 testGroup "Lists" [
86 "bullet" =:
88 "bullet" =: