diff --git a/MANUAL.txt b/MANUAL.txt index 29fc629cd..9fd0e3381 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -2637,7 +2637,10 @@ and lists, and cannot span multiple lines. If a pipe table contains a row whose printable content is wider than the column width (see `--columns`), then the cell contents will wrap, with the relative cell widths determined by the widths of the separator -lines. +lines. (In this case, the table will take up the full text +width.) If no lines are wider than column width, then +cell contents will not be wrapped, and the cells will be sized +to their contents. Note: pandoc also recognizes pipe tables of the following form, as can be produced by Emacs' orgtbl-mode: diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 2d7c12e99..b97a724a4 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1353,8 +1353,8 @@ pipeTable = try $ do numColumns <- getOption readerColumns let widths = if maxlength > numColumns then map (\len -> - fromIntegral (len + 1) / fromIntegral numColumns) - seplengths + fromIntegral (len + 1) / fromIntegral (sum seplengths)) + seplengths else replicate (length aligns) 0.0 return (aligns, widths, heads', sequence lines'') diff --git a/test/pipe-tables.native b/test/pipe-tables.native index 63c2c17bc..6e39dc475 100644 --- a/test/pipe-tables.native +++ b/test/pipe-tables.native @@ -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.125,0.1375,0.5] +,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.1639344262295082,0.18032786885245902,0.6557377049180328] [[Plain [Str "Default1"]] ,[Plain [Str "Default2"]] ,[Plain [Str "Default3"]]]