@@ -38,7 +38,7 @@ module Text.Pandoc.Readers.Groff
3838 , LinePart(..)
3939 , Arg
4040 , TableOption
41− , TableFormat
41+ , TableFormat(..)
4242 , GroffToken(..)
4343 , GroffTokens(..)
4444 , linePartsToString
@@ -89,8 +89,17 @@ data LinePart = RoffStr String
8989 deriving Show
9090
9191type Arg = [LinePart]
92+
9293type TableOption = (String, String)
93−type TableFormat = String
94+
95+data TableFormat =
96+ TableFormat
97+ { columnType :: Char
98+ , pipePrefix :: Bool
99+ , pipeSuffix :: Bool
100+ , columnSuffixes :: [String]
101+ } deriving (Show, Eq, Ord)
102+
94103
95104-- TODO parse tables (see man tbl)
96105data GroffToken = MLine [LinePart]
@@ -383,12 +392,13 @@ tableFormatSpecLine = do
383392 skipMany spacetab
384393 return as
385394
386−tableColFormat :: PandocMonad m => GroffLexer m String
395+tableColFormat :: PandocMonad m => GroffLexer m TableFormat
387396tableColFormat = do
388− pipePrefix <- option "" $ try $ string "|" <* notFollowedBy spacetab
397+ pipePrefix' <- option False
398+ $ True <$ (try $ string "|" <* notFollowedBy spacetab)
389399 c <- oneOf ['a','A','c','C','l','L','n','N','r','R','s','S','^','_','-',
390400 '=','|']
391− numsuffix <- option "" $ many1 digit
401+ numsuffixes <- option [] $ (:[]) <$> many1 digit
392402 suffixes <- many $ do
393403 x <- oneOf ['b','B','d','D','e','E','f','F','i','I','m','M',
394404 'p','P','t','T','u','U','v','V','w','W','x','X', 'z','Z']
@@ -399,8 +409,12 @@ tableColFormat = do
399409 return ("(" ++ xs ++ ")")
400410 else return ""
401411 return $ x : num
402− pipeSuffix <- option "" $ string "|"
403− return $ pipePrefix ++ (c : numsuffix ++ concat suffixes ++ pipeSuffix)
412+ pipeSuffix' <- option False $ True <$ string "|"
413+ return $ TableFormat
414+ { columnType = c
415+ , pipePrefix = pipePrefix'
416+ , pipeSuffix = pipeSuffix'
417+ , columnSuffixes = numsuffixes ++ suffixes }
404418
405419-- We don't fully handle the conditional. But we do
406420-- include everything under '.ie n', which occurs commonly