From 9678538f45258421d12bf12cbf77e7be17f131c3 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 27 Oct 2018 11:10:15 -0700 Subject: Roff tokenizer: allow digit suffix in table cell format in any order. Closes #5026. --- src/Text/Pandoc/Readers/Roff.hs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/Roff.hs b/src/Text/Pandoc/Readers/Roff.hs index e83821ed4..89c0dd166 100644 --- a/src/Text/Pandoc/Readers/Roff.hs +++ b/src/Text/Pandoc/Readers/Roff.hs @@ -424,23 +424,22 @@ tableColFormat = do $ True <$ (try $ string "|" <* notFollowedBy spacetab) c <- oneOf ['a','A','c','C','l','L','n','N','r','R','s','S','^','_','-', '=','|'] - numsuffixes <- option [] $ (:[]) <$> many1 digit - suffixes <- many $ do - x <- oneOf ['b','B','d','D','e','E','f','F','i','I','m','M', + suffixes <- many $ count 1 digit <|> + (do x <- oneOf ['b','B','d','D','e','E','f','F','i','I','m','M', 'p','P','t','T','u','U','v','V','w','W','x','X', 'z','Z'] - num <- if x == 'w' - then many1 digit <|> - do char '(' - xs <- manyTill anyChar (char ')') - return ("(" ++ xs ++ ")") - else return "" - return $ x : num + num <- if x == 'w' + then many1 digit <|> + do char '(' + xs <- manyTill anyChar (char ')') + return ("(" ++ xs ++ ")") + else return "" + return $ x : num) pipeSuffix' <- option False $ True <$ string "|" return $ CellFormat { columnType = c , pipePrefix = pipePrefix' , pipeSuffix = pipeSuffix' - , columnSuffixes = numsuffixes ++ suffixes } + , columnSuffixes = suffixes } -- We don't fully handle the conditional. But we do -- include everything under '.ie n', which occurs commonly -- cgit v1.2.3