git.iko.soy/typeable/pandoc
on master help sign in
Roff tokenizer: better handling of table format strings.

Particularly f and m, which require a space after their argument. Also, allow space before numerical arguments, as in his example from stty.1: ``` .TS center tab(@) box; cB cB | cB cB | cB cB lf5 2 l 6 | lf5 2 l 6 | lf5 2 l. \&^c@Value@^c@Value@^c@Value ```

commitfe73707ab11a054aafad0ef6f1dc0ae54c4f67ad authorJohn MacFarlane <jgm@berkeley.edu> dateSun 28 Oct 2018, 10:41 (8 years ago) parente96bb43
1 file changed+10−8
src/Text/Pandoc/Readers/Roff.hs+10−8
src/Text/Pandoc/Readers/Roff.hs+10−8
@@ -53,7 +53,7 @@ import Control.Monad (void, mzero, guard, when)
5353import Control.Monad.Except (throwError)
5454import Text.Pandoc.Class
5555 (getResourcePath, readFileFromDirs, PandocMonad(..), report)
56−import Data.Char (isHexDigit, chr, ord, isAscii, isAlphaNum, isSpace)
56+import Data.Char (toLower, isHexDigit, chr, ord, isAscii, isAlphaNum, isSpace)
5757import Data.Default (Default)
5858import qualified Data.Map as M
5959import Data.List (intercalate, isSuffixOf)
@@ -423,15 +423,17 @@ tableColFormat = do
423423 $ True <$ (try $ string "|" <* notFollowedBy spacetab)
424424 c <- oneOf ['a','A','c','C','l','L','n','N','r','R','s','S','^','_','-',
425425 '=','|']
426− suffixes <- many $ count 1 digit <|>
426+ suffixes <- many $ (try $ skipMany spacetab *> count 1 digit) <|>
427427 (do x <- oneOf ['b','B','d','D','e','E','f','F','i','I','m','M',
428428 'p','P','t','T','u','U','v','V','w','W','x','X', 'z','Z']
429− num <- if x == 'w'
430− then many1 digit <|>
431− do char '('
432− xs <- manyTill anyChar (char ')')
433− return ("(" ++ xs ++ ")")
434− else return ""
429+ num <- case toLower x of
430+ 'w' -> many1 digit <|>
431+ do char '('
432+ xs <- manyTill anyChar (char ')')
433+ return ("(" ++ xs ++ ")")
434+ 'f' -> count 1 alphaNum <* skipMany spacetab
435+ 'm' -> count 1 alphaNum <* skipMany spacetab
436+ _ -> return ""
435437 return $ x : num)
436438 pipeSuffix' <- option False $ True <$ string "|"
437439 return $ CellFormat