From 805b9f8a1238288ee094b8593cdb24e24636f01d Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 2 Nov 2018 21:35:49 -0700 Subject: Roff reader: Improved handling of custom strings as arguments. Added test. --- src/Text/Pandoc/Readers/Roff.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/Roff.hs b/src/Text/Pandoc/Readers/Roff.hs index fdf9a7f06..0559bab42 100644 --- a/src/Text/Pandoc/Readers/Roff.hs +++ b/src/Text/Pandoc/Readers/Roff.hs @@ -212,6 +212,7 @@ readUnicodeChar _ = Nothing escapeNormal :: PandocMonad m => RoffLexer m [LinePart] escapeNormal = do c <- anyChar + optional expandString case c of ' ' -> return [RoffStr " "] '"' -> mempty <$ skipMany (satisfy (/='\n')) -- line comment @@ -313,13 +314,12 @@ signedNumber = try $ do -- Parses: [..] or (.. escapeArg :: PandocMonad m => RoffLexer m String escapeArg = choice - [ char '[' *> manyTill (expanding $ noneOf ['\n',']']) (char ']') - , char '(' *> count 2 (expanding $ satisfy (/='\n')) + [ char '[' *> optional expandString *> + manyTill (noneOf ['\n',']']) (char ']') + , char '(' *> optional expandString *> + count 2 (satisfy (/='\n')) ] -expanding :: PandocMonad m => RoffLexer m a -> RoffLexer m a -expanding parser = try $ optional expandString >> parser - expandString :: PandocMonad m => RoffLexer m () expandString = try $ do pos <- getPosition @@ -336,7 +336,7 @@ quoteArg = char '\'' *> manyTill (noneOf ['\n','\'']) (char '\'') escFont :: PandocMonad m => RoffLexer m [LinePart] escFont = do - font <- expanding (escapeArg <|> count 1 alphaNum) + font <- escapeArg <|> count 1 alphaNum font' <- if null font || font == "P" then prevFont <$> getState else return $ foldr processFontLetter defaultFontSpec font -- cgit v1.2.3