Markdown: Improved computation of relative cell widths in pipe tables.

This commit is contained in:
John MacFarlane 2017-12-12 15:36:29 -08:00
parent e86c337356
commit 7093a3b44c
3 changed files with 5 additions and 5 deletions

View file

@ -1353,7 +1353,7 @@ pipeTable = try $ do
numColumns <- getOption readerColumns
let widths = if maxlength > numColumns
then map (\len ->
fromIntegral (len + 1) / fromIntegral (sum seplengths))
fromIntegral len / fromIntegral (sum seplengths))
seplengths
else replicate (length aligns) 0.0
return (aligns, widths, heads', sequence lines'')

View file

@ -6,9 +6,9 @@
^D
<table>
<colgroup>
<col style="width: 15%" />
<col style="width: 8%" />
<col style="width: 76%" />
<col style="width: 14%" />
<col style="width: 7%" />
<col style="width: 77%" />
</colgroup>
<thead>
<tr class="header">

View file

@ -85,7 +85,7 @@
,[[Plain [Str "4"]]
,[Plain [Str "44"]]]]
,Para [Str "Long",Space,Str "pipe",Space,Str "table",Space,Str "with",Space,Str "relative",Space,Str "widths:"]
,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.1639344262295082,0.18032786885245902,0.6557377049180328]
,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.15517241379310345,0.1724137931034483,0.6724137931034483]
[[Plain [Str "Default1"]]
,[Plain [Str "Default2"]]
,[Plain [Str "Default3"]]]