diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-11-02 21:35:49 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-11-02 21:35:49 -0700 |
commit | 805b9f8a1238288ee094b8593cdb24e24636f01d (patch) | |
tree | 2c3d999e9dfaac51f88974f51d7fcbf342c7879f /src/Text/Pandoc/Readers | |
parent | e95aeeafb89eed801c574aeafc05d9eeaff1bd0f (diff) | |
download | pandoc-805b9f8a1238288ee094b8593cdb24e24636f01d.tar.gz |
Roff reader: Improved handling of custom strings as arguments.
Added test.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/Roff.hs | 12 |
1 files changed, 6 insertions, 6 deletions
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 |