diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-01-16 23:13:33 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-01-16 23:13:33 -0800 |
commit | d987a9d1142c092798694c650856ed0c371641ac (patch) | |
tree | d9080460cb01462fec9c898085151d6b5d660f67 | |
parent | 24acb714c185139ef3a02a7437cd1c64f85c0198 (diff) | |
download | pandoc-d987a9d1142c092798694c650856ed0c371641ac.tar.gz |
Markdown writer: fix cell width calculation.
Previously we could get ever-lengthening cell widths
when a table was run repeatedly through `pandoc -f markdown -t
markdown`. This patch stabilizes the relative cell
widths. Closes #4265.
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 2 | ||||
-rw-r--r-- | test/tables.markdown | 16 | ||||
-rw-r--r-- | test/tables.plain | 16 |
3 files changed, 17 insertions, 17 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 08dff2c4e..c8b3a1526 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -701,7 +701,7 @@ pandocTable opts multiline headless aligns widths rawHeaders rawRows = do let columns = transpose (rawHeaders : rawRows) -- minimal column width without wrapping a single word let relWidth w col = - max (floor $ fromIntegral (writerColumns opts) * w) + max (floor $ fromIntegral (writerColumns opts - 1) * w) (if writerWrapText opts == WrapAuto then minNumChars col else numChars col) diff --git a/test/tables.markdown b/test/tables.markdown index 7f89bfc08..f5ee776fa 100644 --- a/test/tables.markdown +++ b/test/tables.markdown @@ -28,33 +28,33 @@ Simple table indented two spaces: Multiline table with caption: - -------------------------------------------------------------- + ------------------------------------------------------------- Centered Left Right Default aligned Header Aligned Aligned - ----------- ---------- ------------ -------------------------- + ----------- ---------- ------------ ------------------------- First row 12.0 Example of a row that spans multiple lines. Second row 5.0 Here's another one. Note the blank line between rows. - -------------------------------------------------------------- + ------------------------------------------------------------- : Here's the caption. It may span multiple lines. Multiline table without caption: - -------------------------------------------------------------- + ------------------------------------------------------------- Centered Left Right Default aligned Header Aligned Aligned - ----------- ---------- ------------ -------------------------- + ----------- ---------- ------------ ------------------------- First row 12.0 Example of a row that spans multiple lines. Second row 5.0 Here's another one. Note the blank line between rows. - -------------------------------------------------------------- + ------------------------------------------------------------- Table without column headers: @@ -66,11 +66,11 @@ Table without column headers: Multiline table without column headers: - ----------- ---------- ------------ -------------------------- + ----------- ---------- ------------ ------------------------- First row 12.0 Example of a row that spans multiple lines. Second row 5.0 Here's another one. Note the blank line between rows. - ----------- ---------- ------------ -------------------------- + ----------- ---------- ------------ ------------------------- diff --git a/test/tables.plain b/test/tables.plain index e46317a6f..7013d0caa 100644 --- a/test/tables.plain +++ b/test/tables.plain @@ -28,33 +28,33 @@ Simple table indented two spaces: Multiline table with caption: - -------------------------------------------------------------- + ------------------------------------------------------------- Centered Left Right Default aligned Header Aligned Aligned - ----------- ---------- ------------ -------------------------- + ----------- ---------- ------------ ------------------------- First row 12.0 Example of a row that spans multiple lines. Second row 5.0 Here’s another one. Note the blank line between rows. - -------------------------------------------------------------- + ------------------------------------------------------------- : Here’s the caption. It may span multiple lines. Multiline table without caption: - -------------------------------------------------------------- + ------------------------------------------------------------- Centered Left Right Default aligned Header Aligned Aligned - ----------- ---------- ------------ -------------------------- + ----------- ---------- ------------ ------------------------- First row 12.0 Example of a row that spans multiple lines. Second row 5.0 Here’s another one. Note the blank line between rows. - -------------------------------------------------------------- + ------------------------------------------------------------- Table without column headers: @@ -66,11 +66,11 @@ Table without column headers: Multiline table without column headers: - ----------- ---------- ------------ -------------------------- + ----------- ---------- ------------ ------------------------- First row 12.0 Example of a row that spans multiple lines. Second row 5.0 Here’s another one. Note the blank line between rows. - ----------- ---------- ------------ -------------------------- + ----------- ---------- ------------ ------------------------- |