git.iko.soy/typeable/pandoc
on master help sign in
Roff reader: properly handle unknown backslash escapes.

They are treated as regular characters, according to groff 7. Cloess #5034.

commit3305a018bc38a435a7bd006f9447d97ee3ea6868 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 30 Oct 2018, 15:54 (8 years ago) parente874bc2
2 files changed+6−1
src/Text/Pandoc/Readers/Roff.hs+4−1 test/Tests/Readers/Man.hs+2
src/Text/Pandoc/Readers/Roff.hs+4−1
@@ -284,7 +284,10 @@ escapeNormal = do
284284 CopyMode -> char '\\'
285285 NormalMode -> return '\\'
286286 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."
288291
289292escIgnore :: PandocMonad m
290293 => Char
test/Tests/Readers/Man.hs+2
@@ -81,6 +81,8 @@ tests = [
8181 "\\[u2020]" =?> (para $ text "†")
8282 , "unicode escapes (combined)" =:
8383 "\\[u0075_u0301]" =?> (para $ text "\250")
84+ , "unknown escape (#5034)" =:
85+ "\\9" =?> (para $ text "9")
8486 ],
8587 testGroup "Lists" [
8688 "bullet" =: