@@ -55,13 +55,15 @@ import qualified Text.Parsec as Parsec
5555import Text.Parsec.Pos (updatePosString, initialPos)
5656import qualified Data.Foldable as Foldable
5757
58−data ManState = ManState { readerOptions :: ReaderOptions
59− , metadata :: Meta
58+data ManState = ManState { readerOptions :: ReaderOptions
59+ , metadata :: Meta
60+ , tableCellsPlain :: Bool
6061 } deriving Show
6162
6263instance Default ManState where
63− def = ManState { readerOptions = def
64− , metadata = nullMeta }
64+ def = ManState { readerOptions = def
65+ , metadata = nullMeta
66+ , tableCellsPlain = True }
6567
6668type ManParser m = ParserT [RoffToken] ManState m
6769
@@ -111,6 +113,7 @@ parseBlock = choice [ parseList
111113
112114parseTable :: PandocMonad m => ManParser m Blocks
113115parseTable = do
116+ modifyState $ \st -> st { tableCellsPlain = True }
114117 let isMTable (MTable{}) = True
115118 isMTable _ = False
116119 MTable _opts rows pos <- msatisfy isMTable
@@ -126,7 +129,12 @@ parseTable = do
126129 _ -> (([],[]), rows)
127130 headerRow <- mapM parseTableCell $ snd headerRow'
128131 bodyRows <- mapM (mapM parseTableCell . snd) bodyRows'
129− return $ B.table mempty (zip alignments (repeat 0.0))
132+ isPlainTable <- tableCellsPlain <$> getState
133+ let widths = if isPlainTable
134+ then repeat 0.0
135+ else repeat ((1.0 / fromIntegral (length alignments))
136+ :: Double)
137+ return $ B.table mempty (zip alignments widths)
130138 headerRow bodyRows) <|> fallback pos
131139 [] -> fallback pos
132140
@@ -135,14 +143,23 @@ parseTable = do
135143 parseTableCell ts = do
136144 st <- getState
137145 let ts' = Foldable.toList $ unRoffTokens ts
138− let tcell = try $ do
146+ let plaintcell = try $ do
139147 skipMany memptyLine
140148 plain . trimInlines <$> (parseInlines <* eof)
149+ let blockstcell = try $ do
150+ skipMany memptyLine
151+ mconcat <$> many parseBlock <* eof
141152 res <- if null ts'
142153 then return $ Right mempty
143− else lift $ readWithMTokens tcell st ts'
154+ else lift $ readWithMTokens plaintcell st ts'
144155 case res of
145− Left _ -> fail "Could not parse table cell"
156+ Left _ -> do
157+ res' <- lift $ readWithMTokens blockstcell st ts'
158+ case res' of
159+ Left _ -> fail "Could not parse table cell"
160+ Right x -> do
161+ modifyState $ \s -> s{ tableCellsPlain = False }
162+ return x
146163 Right x -> return x
147164
148165 isHrule :: TableRow -> Bool