diff options
Diffstat (limited to 'src/Text/Pandoc/Parsing.hs')
-rw-r--r-- | src/Text/Pandoc/Parsing.hs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs index 9032fc7bd..f79d0fdfc 100644 --- a/src/Text/Pandoc/Parsing.hs +++ b/src/Text/Pandoc/Parsing.hs @@ -925,9 +925,16 @@ tableWith :: (Stream s m Char, HasReaderOptions st, Monad mf) tableWith headerParser rowParser lineParser footerParser = try $ do (aligns, widths, heads, rows) <- tableWith' headerParser rowParser lineParser footerParser - return $ B.table mempty (zip aligns widths) <$> heads <*> rows + let th = TableHead nullAttr <$> heads + tb = (:[]) . TableBody nullAttr 0 [] <$> rows + tf = pure $ TableFoot nullAttr [] + return $ B.table B.emptyCaption (zip aligns (map fromWidth widths)) <$> th <*> tb <*> tf + where + fromWidth n + | n > 0 = ColWidth n + | otherwise = ColWidthDefault -type TableComponents mf = ([Alignment], [Double], mf [Blocks], mf [[Blocks]]) +type TableComponents mf = ([Alignment], [Double], mf [Row], mf [Row]) tableWith' :: (Stream s m Char, HasReaderOptions st, Monad mf) => ParserT s st m (mf [Blocks], [Alignment], [Int]) @@ -943,7 +950,9 @@ tableWith' headerParser rowParser lineParser footerParser = try $ do let widths = if null indices then replicate (length aligns) 0.0 else widthsFromIndices numColumns indices - return (aligns, widths, heads, lines') + let toRow = Row nullAttr . map B.simpleCell + toHeaderRow l = if null l then [] else [toRow l] + return (aligns, widths, toHeaderRow <$> heads, map toRow <$> lines') -- Calculate relative widths of table columns, based on indices widthsFromIndices :: Int -- Number of columns on terminal |