diff options
Diffstat (limited to 'Pancake/Rendering.hs')
-rw-r--r-- | Pancake/Rendering.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Pancake/Rendering.hs b/Pancake/Rendering.hs index 0149655..6c6f4e2 100644 --- a/Pancake/Rendering.hs +++ b/Pancake/Rendering.hs @@ -436,8 +436,10 @@ renderBlock (P.Table caption aligns widths headers rows) = do ws <- if widthsAreSet then pure widths else do lens <- map sum . transpose <$> mapM (mapM (fmap (length . unstyled . concat . rLines) . renderCell 80)) rows - pure $ map (\l -> fromIntegral l / fromIntegral (sum lens) * 0.7 - + 1 / fromIntegral (length lens) * 0.3) lens + pure $ map (\l -> if sum lens == 0 || length lens == 0 + then 0 + else fromIntegral l / fromIntegral (sum lens) * 0.7 + + 1 / fromIntegral (length lens) * 0.3) lens let withHead = if all null headers then id else (headers :) mapM_ (\r -> renderBlock P.HorizontalRule >> tableRow ws r) (withHead rows) renderBlock P.HorizontalRule |