git.iko.soy/typeable/pandoc
on master help sign in
Pipe tables: use full text width for tables with wrapping cells.

Previously we computed the column sizes based on the ratio between the header lines and the text width (as set by `--columns`). This meant that tables with very short header lines would be very narrow. With this change, pipe tables with wrapping cells will always take up the whole text width. The relative column widths will still be determined by the ratio of header lines, but they will be normalized to add up to 1.0.

commite86c337356fc723e366e5f0d6209205bcffe88f3 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 12 Dec 2017, 15:16 (9 years ago) parent7d23031
3 files changed+7−4
MANUAL.txt+4−1 src/Text/Pandoc/Readers/Markdown.hs+2−2 test/pipe-tables.native+1−1
MANUAL.txt+4−1
@@ -2637,7 +2637,10 @@ and lists, and cannot span multiple lines. If a pipe table contains a
26372637row whose printable content is wider than the column width (see
26382638`--columns`), then the cell contents will wrap, with the
26392639relative cell widths determined by the widths of the separator
2640−lines.
2640+lines. (In this case, the table will take up the full text
2641+width.) If no lines are wider than column width, then
2642+cell contents will not be wrapped, and the cells will be sized
2643+to their contents.
26412644
26422645Note: pandoc also recognizes pipe tables of the following
26432646form, as can be produced by Emacs' orgtbl-mode:
src/Text/Pandoc/Readers/Markdown.hs+2−2
@@ -1353,8 +1353,8 @@ pipeTable = try $ do
13531353 numColumns <- getOption readerColumns
13541354 let widths = if maxlength > numColumns
13551355 then map (\len ->
1356− fromIntegral (len + 1) / fromIntegral numColumns)
1357− seplengths
1356+ fromIntegral (len + 1) / fromIntegral (sum seplengths))
1357+ seplengths
13581358 else replicate (length aligns) 0.0
13591359 return (aligns, widths, heads', sequence lines'')
13601360
test/pipe-tables.native+1−1
@@ -85,7 +85,7 @@
8585 ,[[Plain [Str "4"]]
8686 ,[Plain [Str "44"]]]]
8787,Para [Str "Long",Space,Str "pipe",Space,Str "table",Space,Str "with",Space,Str "relative",Space,Str "widths:"]
88−,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.125,0.1375,0.5]
88+,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.1639344262295082,0.18032786885245902,0.6557377049180328]
8989 [[Plain [Str "Default1"]]
9090 ,[Plain [Str "Default2"]]
9191 ,[Plain [Str "Default3"]]]