@@ -537,8 +537,16 @@ blockToMarkdown' opts t@(Table caption aligns widths headers rows) = do
537537 isEnabled Ext_multiline_tables opts -> fmap (nest 2,) $
538538 pandocTable opts (all null headers) aligns widths
539539 rawHeaders rawRows
540− | isEnabled Ext_grid_tables opts -> fmap (id,) $
541− gridTable opts (all null headers) aligns widths
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)
545+ else widths
546+ let widthsInChars = map ((\x -> x - 3) . floor .
547+ (fromIntegral (writerColumns opts) *)) widths'
548+ fmap (id,) $
549+ gridTable (all null headers) aligns widthsInChars
542550 rawHeaders rawRows
543551 | isEnabled Ext_raw_html opts -> fmap (id,) $
544552 text <$>
@@ -657,15 +665,9 @@ pandocTable opts headless aligns widths rawHeaders rawRows = do
657665 else border
658666 return $ head'' $$ underline $$ body $$ bottom
659667
660−gridTable :: PandocMonad m => WriterOptions -> Bool -> [Alignment] -> [Double]
668+gridTable :: PandocMonad m => Bool -> [Alignment] -> [Int]
661669 -> [Doc] -> [[Doc]] -> MD m Doc
662−gridTable opts headless aligns widths headers' rawRows = do
663− let numcols = length headers'
664− let widths' = if all (==0) widths
665− then replicate numcols (1.0 / fromIntegral numcols)
666− else widths
667− let widthsInChars = map
668− ((\x -> x - 3) . floor . (fromIntegral (writerColumns opts) *)) widths'
670+gridTable headless aligns widthsInChars headers' rawRows = do
669671 let hpipeBlocks blocks = hcat [beg, middle, end]
670672 where h = maximum (1 : map height blocks)
671673 sep' = lblock 3 $ vcat (map text $ replicate h " | ")