@@ -537,8 +537,16 @@ blockToMarkdown' opts t@(Table caption aligns widths headers rows) = do
537 isEnabled Ext_multiline_tables opts -> fmap (nest 2,) $
537 isEnabled Ext_multiline_tables opts -> fmap (nest 2,) $
538 pandocTable opts (all null headers) aligns widths
538 pandocTable opts (all null headers) aligns widths
539 rawHeaders rawRows
539 rawHeaders rawRows
540− | isEnabled Ext_grid_tables opts -> fmap (id,) $
540+ | isEnabled Ext_grid_tables opts -> do
541+ let numcols = length headers
542+ let widths' = if all (==0) widths
543+ then replicate numcols
544+ (1.0 / fromIntegral numcols)
546+ let widthsInChars = map ((\x -> x - 3) . floor .
547+ (fromIntegral (writerColumns opts) *)) widths'
541− gridTable opts (all null headers) aligns widths
549+ gridTable (all null headers) aligns widthsInChars
542 rawHeaders rawRows
550 rawHeaders rawRows
543 | isEnabled Ext_raw_html opts -> fmap (id,) $
551 | isEnabled Ext_raw_html opts -> fmap (id,) $
@@ -657,15 +665,9 @@ pandocTable opts headless aligns widths rawHeaders rawRows = do
657 else border
665 else border
658 return $ head'' $$ underline $$ body $$ bottom
666 return $ head'' $$ underline $$ body $$ bottom
660−gridTable :: PandocMonad m => WriterOptions -> Bool -> [Alignment] -> [Double]
668+gridTable :: PandocMonad m => Bool -> [Alignment] -> [Int]
661 -> [Doc] -> [[Doc]] -> MD m Doc
669 -> [Doc] -> [[Doc]] -> MD m Doc
662−gridTable opts headless aligns widths headers' rawRows = do
670+gridTable headless aligns widthsInChars headers' rawRows = do
663− let numcols = length headers'
664− let widths' = if all (==0) widths
665− then replicate numcols (1.0 / fromIntegral numcols)
667− let widthsInChars = map
668− ((\x -> x - 3) . floor . (fromIntegral (writerColumns opts) *)) widths'
669 let hpipeBlocks blocks = hcat [beg, middle, end]
671 let hpipeBlocks blocks = hcat [beg, middle, end]
670 where h = maximum (1 : map height blocks)
672 where h = maximum (1 : map height blocks)
671 sep' = lblock 3 $ vcat (map text $ replicate h " | ")
673 sep' = lblock 3 $ vcat (map text $ replicate h " | ")