git.iko.soy/typeable/pandoc
on master help sign in
Pipe tables: use full text width for tables with wrapping cells.
e86c337John MacFarlane
MANUAL.txt+4−1
@@ -2637,7 +2637,10 @@ and lists, and cannot span multiple lines. If a pipe table contains a
2637row whose printable content is wider than the column width (see
2637row whose printable content is wider than the column width (see
2638`--columns`), then the cell contents will wrap, with the
2638`--columns`), then the cell contents will wrap, with the
2639relative cell widths determined by the widths of the separator
2639relative 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.
2641
2644
2642Note: pandoc also recognizes pipe tables of the following
2645Note: pandoc also recognizes pipe tables of the following
2643form, as can be produced by Emacs' orgtbl-mode:
2646form, as can be produced by Emacs' orgtbl-mode:
src/Text/Pandoc/Readers/Markdown.hs+2−2
@@ -1353,8 +1353,8 @@ pipeTable = try $ do
1353 numColumns <- getOption readerColumns
1353 numColumns <- getOption readerColumns
1354 let widths = if maxlength > numColumns
1354 let widths = if maxlength > numColumns
1355 then map (\len ->
1355 then map (\len ->
1356− fromIntegral (len + 1) / fromIntegral numColumns)
1356+ fromIntegral (len + 1) / fromIntegral (sum seplengths))
1357− seplengths
1357+ seplengths
1358 else replicate (length aligns) 0.0
1358 else replicate (length aligns) 0.0
1359 return (aligns, widths, heads', sequence lines'')
1359 return (aligns, widths, heads', sequence lines'')
1360
1360
test/pipe-tables.native+1−1
@@ -85,7 +85,7 @@
85 ,[[Plain [Str "4"]]
85 ,[[Plain [Str "4"]]
86 ,[Plain [Str "44"]]]]
86 ,[Plain [Str "44"]]]]
87,Para [Str "Long",Space,Str "pipe",Space,Str "table",Space,Str "with",Space,Str "relative",Space,Str "widths:"]
87,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]
89 [[Plain [Str "Default1"]]
89 [[Plain [Str "Default1"]]
90 ,[Plain [Str "Default2"]]
90 ,[Plain [Str "Default2"]]
91 ,[Plain [Str "Default3"]]]
91 ,[Plain [Str "Default3"]]]