@@ -33,7 +33,7 @@ import Control.Monad.Except (throwError)
3333import Text.Pandoc.Class
3434 (getResourcePath, readFileFromDirs, PandocMonad(..), report)
3535import Data.Char (isLower, toLower, toUpper, chr,
36− isAscii, isAlphaNum, isSpace)
36+ isAscii, isAlphaNum)
3737import Data.Default (Default)
3838import qualified Data.Map as M
3939import Data.List (intercalate)
@@ -130,7 +130,7 @@ type RoffLexer m = ParserT [Char] RoffState m
130130--
131131
132132eofline :: Stream s m Char => ParsecT s u m ()
133−eofline = void newline <|> eof
133+eofline = void newline <|> eof <|> () <$ lookAhead (string "\\}")
134134
135135spacetab :: Stream s m Char => ParsecT s u m Char
136136spacetab = char ' ' <|> char '\t'
@@ -144,7 +144,7 @@ combiningAccentsMap =
144144 M.fromList $ map (\(x,y) -> (y,x)) combiningAccents
145145
146146escape :: PandocMonad m => RoffLexer m [LinePart]
147−escape = do
147+escape = try $ do
148148 backslash
149149 escapeGlyph <|> escapeNormal
150150
@@ -193,7 +193,7 @@ readUnicodeChar _ = Nothing
193193
194194escapeNormal :: PandocMonad m => RoffLexer m [LinePart]
195195escapeNormal = do
196− c <- anyChar
196+ c <- noneOf "{}"
197197 optional expandString
198198 case c of
199199 ' ' -> return [RoffStr " "]
@@ -256,9 +256,7 @@ escapeNormal = do
256256 'w' -> escIgnore 'w' [quoteArg]
257257 'x' -> escIgnore 'x' [quoteArg]
258258 'z' -> escIgnore 'z' [count 1 anyChar]
259− '{' -> return mempty
260259 '|' -> return [RoffStr "\x2006"] --1/6 em space
261− '}' -> return mempty
262260 '~' -> return [RoffStr "\160"] -- nonbreaking space
263261 '\\' -> do
264262 mode <- roffMode <$> getState
@@ -350,7 +348,7 @@ lexMacro = do
350348 guard $ sourceColumn pos == 1 || afterConditional st
351349 char '.' <|> char '\''
352350 skipMany spacetab
353− macroName <- many (satisfy (not . isSpace))
351+ macroName <- many (satisfy isAlphaNum)
354352 case macroName of
355353 "nop" -> return mempty
356354 "ie" -> lexConditional "ie"
@@ -361,8 +359,6 @@ lexMacro = do
361359 args <- lexArgs
362360 case macroName of
363361 "" -> return mempty
364− "\\\"" -> return mempty
365− "\\#" -> return mempty
366362 "TS" -> lexTable pos
367363 "de" -> lexMacroDef args
368364 "de1" -> lexMacroDef args