@@ -37,6 +37,7 @@ module Text.Pandoc.Readers.Groff
3737 , defaultFontSpec
3838 , LinePart(..)
3939 , Arg
40+ , TableOption
4041 , GroffToken(..)
4142 , GroffTokens(..)
4243 , linePartsToString
@@ -87,12 +88,13 @@ data LinePart = RoffStr String
8788 deriving Show
8889
8990type Arg = [LinePart]
91+type TableOption = (String, String)
9092
9193-- TODO parse tables (see man tbl)
9294data GroffToken = MLine [LinePart]
9395 | MEmptyLine
9496 | MMacro MacroKind [Arg] SourcePos
95− | MTable [[String]] [[GroffTokens]] SourcePos
97+ | MTable [TableOption] [[String]] [[GroffTokens]] SourcePos
9698 deriving Show
9799
98100newtype GroffTokens = GroffTokens { unGroffTokens :: Seq.Seq GroffToken }
@@ -325,12 +327,15 @@ lexMacro = do
325327lexTable :: PandocMonad m => SourcePos -> GroffLexer m GroffTokens
326328lexTable pos = do
327329 spaces
328− optional tableOptions
330+ opts <- option [] tableOptions
331+ case lookup "tab" opts of
332+ Just (c:_) -> modifyState $ \st -> st{ tableTabChar = c }
333+ _ -> modifyState $ \st -> st{ tableTabChar = '\t' }
329334 spaces
330335 aligns <- tableFormatSpec
331336 spaces
332337 rows <- manyTill tableRow (try (string ".TE" >> skipMany spacetab >> eofline))
333− return $ singleTok $ MTable aligns rows pos
338+ return $ singleTok $ MTable opts aligns rows pos
334339
335340tableCell :: PandocMonad m => GroffLexer m GroffTokens
336341tableCell = (enclosedCell <|> simpleCell) >>= lexGroff . T.pack
@@ -351,15 +356,10 @@ tableRow = do
351356 eofline
352357 return (c:cs)
353358
354−tableOptions :: PandocMonad m => GroffLexer m ()
355−tableOptions = try $ do
356− opts <- many1 tableOption <* spaces <* char ';'
357− case lookup "tab" opts of
358− Just (c:_) -> modifyState $ \st -> st{ tableTabChar = c }
359− _ -> modifyState $ \st -> st{ tableTabChar = '\t' }
360− return ()
359+tableOptions :: PandocMonad m => GroffLexer m [TableOption]
360+tableOptions = try $ many1 tableOption <* spaces <* char ';'
361361
362−tableOption :: PandocMonad m => GroffLexer m (String, String)
362+tableOption :: PandocMonad m => GroffLexer m TableOption
363363tableOption = do
364364 k <- many1 letter
365365 v <- option "" $ do