aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-10-30 15:54:29 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-10-30 15:54:29 -0700
commit3305a018bc38a435a7bd006f9447d97ee3ea6868 (patch)
treec8002ce008816d5235e0709dce0f3772d9c4a123
parente874bc2c28fa8651446dd8b8fe6f43339b27de3a (diff)
downloadpandoc-3305a018bc38a435a7bd006f9447d97ee3ea6868.tar.gz
Roff reader: properly handle unknown backslash escapes.
They are treated as regular characters, according to groff 7. Cloess #5034.
-rw-r--r--src/Text/Pandoc/Readers/Roff.hs5
-rw-r--r--test/Tests/Readers/Man.hs2
2 files changed, 6 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Roff.hs b/src/Text/Pandoc/Readers/Roff.hs
index a540cc39d..9e3315cb3 100644
--- a/src/Text/Pandoc/Readers/Roff.hs
+++ b/src/Text/Pandoc/Readers/Roff.hs
@@ -284,7 +284,10 @@ escapeNormal = do
CopyMode -> char '\\'
NormalMode -> return '\\'
return [RoffStr "\\"]
- _ -> fail $ "Unknown escape character \\" ++ [c]
+ _ -> return [RoffStr [c]]
+ -- man 7 groff: "If a backslash is followed by a character that
+ -- does not constitute a defined escape sequence, the backslash
+ -- is silently ignored and the character maps to itself."
escIgnore :: PandocMonad m
=> Char
diff --git a/test/Tests/Readers/Man.hs b/test/Tests/Readers/Man.hs
index c1bf10c80..d58a59dae 100644
--- a/test/Tests/Readers/Man.hs
+++ b/test/Tests/Readers/Man.hs
@@ -81,6 +81,8 @@ tests = [
"\\[u2020]" =?> (para $ text "†")
, "unicode escapes (combined)" =:
"\\[u0075_u0301]" =?> (para $ text "\250")
+ , "unknown escape (#5034)" =:
+ "\\9" =?> (para $ text "9")
],
testGroup "Lists" [
"bullet" =: