From 6b8e595e7285210f018186af93cee3df23da9060 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 28 Oct 2018 20:41:17 -0700 Subject: Roff reader: use escapeArg in macroArg. --- src/Text/Pandoc/Readers/Roff.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc/Readers/Roff.hs') diff --git a/src/Text/Pandoc/Readers/Roff.hs b/src/Text/Pandoc/Readers/Roff.hs index cf9056aa7..7383d95ae 100644 --- a/src/Text/Pandoc/Readers/Roff.hs +++ b/src/Text/Pandoc/Readers/Roff.hs @@ -53,7 +53,7 @@ import Control.Monad (void, mzero, guard, when, mplus) import Control.Monad.Except (throwError) import Text.Pandoc.Class (getResourcePath, readFileFromDirs, PandocMonad(..), report) -import Data.Char (isLower, toLower, toUpper, chr, ord, +import Data.Char (isLower, toLower, toUpper, chr, isAscii, isAlphaNum, isSpace) import Data.Default (Default) import qualified Data.Map as M @@ -602,9 +602,14 @@ linePart = macroArg <|> escape <|> macroArg :: PandocMonad m => RoffLexer m [LinePart] macroArg = try $ do + pos <- getPosition string "\\\\$" - x <- digit - return [MacroArg $ ord x - ord '0'] + x <- escapeArg <|> count 1 digit + case safeRead x of + Just i -> return [MacroArg i] + Nothing -> do + report $ SkippedContent ("illegal macro argument " ++ x) pos + return [] regularText :: PandocMonad m => RoffLexer m [LinePart] regularText = do -- cgit v1.2.3