git.iko.soy/typeable/pandoc
on master help sign in
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.

commitd987a9d1142c092798694c650856ed0c371641ac authorJohn MacFarlane <jgm@berkeley.edu> dateTue 16 Jan 2018, 23:13 (9 years ago) parent24acb71
3 files changed+17−17
src/Text/Pandoc/Writers/Markdown.hs+1−1 test/tables.markdown+8−8 test/tables.plain+8−8
src/Text/Pandoc/Writers/Markdown.hs+1−1
@@ -701,7 +701,7 @@ pandocTable opts multiline headless aligns widths rawHeaders rawRows = do
701701 let columns = transpose (rawHeaders : rawRows)
702702 -- minimal column width without wrapping a single word
703703 let relWidth w col =
704− max (floor $ fromIntegral (writerColumns opts) * w)
704+ max (floor $ fromIntegral (writerColumns opts - 1) * w)
705705 (if writerWrapText opts == WrapAuto
706706 then minNumChars col
707707 else numChars col)
test/tables.markdown+8−8
@@ -28,33 +28,33 @@ Simple table indented two spaces:
2828
2929Multiline table with caption:
3030
31− --------------------------------------------------------------
31+ -------------------------------------------------------------
3232 Centered Left Right Default aligned
3333 Header Aligned Aligned
34− ----------- ---------- ------------ --------------------------
34+ ----------- ---------- ------------ -------------------------
3535 First row 12.0 Example of a row that
3636 spans multiple lines.
3737
3838 Second row 5.0 Here's another one. Note
3939 the blank line between
4040 rows.
41− --------------------------------------------------------------
41+ -------------------------------------------------------------
4242
4343 : Here's the caption. It may span multiple lines.
4444
4545Multiline table without caption:
4646
47− --------------------------------------------------------------
47+ -------------------------------------------------------------
4848 Centered Left Right Default aligned
4949 Header Aligned Aligned
50− ----------- ---------- ------------ --------------------------
50+ ----------- ---------- ------------ -------------------------
5151 First row 12.0 Example of a row that
5252 spans multiple lines.
5353
5454 Second row 5.0 Here's another one. Note
5555 the blank line between
5656 rows.
57− --------------------------------------------------------------
57+ -------------------------------------------------------------
5858
5959Table without column headers:
6060
@@ -66,11 +66,11 @@ Table without column headers:
6666
6767Multiline table without column headers:
6868
69− ----------- ---------- ------------ --------------------------
69+ ----------- ---------- ------------ -------------------------
7070 First row 12.0 Example of a row that
7171 spans multiple lines.
7272
7373 Second row 5.0 Here's another one. Note
7474 the blank line between
7575 rows.
76− ----------- ---------- ------------ --------------------------
76+ ----------- ---------- ------------ -------------------------
test/tables.plain+8−8
@@ -28,33 +28,33 @@ Simple table indented two spaces:
2828
2929Multiline table with caption:
3030
31− --------------------------------------------------------------
31+ -------------------------------------------------------------
3232 Centered Left Right Default aligned
3333 Header Aligned Aligned
34− ----------- ---------- ------------ --------------------------
34+ ----------- ---------- ------------ -------------------------
3535 First row 12.0 Example of a row that
3636 spans multiple lines.
3737
3838 Second row 5.0 Here’s another one. Note
3939 the blank line between
4040 rows.
41− --------------------------------------------------------------
41+ -------------------------------------------------------------
4242
4343 : Here’s the caption. It may span multiple lines.
4444
4545Multiline table without caption:
4646
47− --------------------------------------------------------------
47+ -------------------------------------------------------------
4848 Centered Left Right Default aligned
4949 Header Aligned Aligned
50− ----------- ---------- ------------ --------------------------
50+ ----------- ---------- ------------ -------------------------
5151 First row 12.0 Example of a row that
5252 spans multiple lines.
5353
5454 Second row 5.0 Here’s another one. Note
5555 the blank line between
5656 rows.
57− --------------------------------------------------------------
57+ -------------------------------------------------------------
5858
5959Table without column headers:
6060
@@ -66,11 +66,11 @@ Table without column headers:
6666
6767Multiline table without column headers:
6868
69− ----------- ---------- ------------ --------------------------
69+ ----------- ---------- ------------ -------------------------
7070 First row 12.0 Example of a row that
7171 spans multiple lines.
7272
7373 Second row 5.0 Here’s another one. Note
7474 the blank line between
7575 rows.
76− ----------- ---------- ------------ --------------------------
76+ ----------- ---------- ------------ -------------------------