summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2024-01-18 08:34:09 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2024-01-18 08:35:21 -0800
commitdf1944f7740599896f0e3d3de1be2e6aafb62d6c (patch)
treecc7f60659899c0cedc674df23bb9a42fd9443d60
parent18f0b70d40e18c2c5b34c20a45f7b625a917b5a4 (diff)
Markdown writer: fix output for pipe tables...
...with a huge number of columns. Previously we got invalid pipe tables when the number of table columns exceeded the setting of `--columns`. Closes #9346.
-rw-r--r--src/Text/Pandoc/Writers/Markdown/Table.hs4
-rw-r--r--test/command/9346.md8
2 files changed, 11 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown/Table.hs b/src/Text/Pandoc/Writers/Markdown/Table.hs
index b2a220b10..caef0a0ea 100644
--- a/src/Text/Pandoc/Writers/Markdown/Table.hs
+++ b/src/Text/Pandoc/Writers/Markdown/Table.hs
@@ -50,7 +50,9 @@ pipeTable opts headless aligns widths rawHeaders rawRows = do
not (all (== 0) widths) &&
maxwidth + (numcols + 1) > colwidth
then map
- (floor . (* fromIntegral (colwidth - (numcols +1))))
+ (max 0 .
+ floor .
+ (* fromIntegral (colwidth - (numcols +1))))
widths
else contentWidths
let torow cs = nowrap $ literal "|" <>
diff --git a/test/command/9346.md b/test/command/9346.md
new file mode 100644
index 000000000..b09970914
--- /dev/null
+++ b/test/command/9346.md
@@ -0,0 +1,8 @@
+```
+% pandoc -f markdown -t markdown_strict+pipe_tables
+|V1 |V2 |V3 |V4 |V5 |V6 |V7 |V8 |V9 |V10 |V11 |V12 |V13 |V14 |V15 |V16 |V17 |V18 |V19 |V20 |V21 |V22 |V23 |V24 |V25 |V26 |V27 |V28 |V29 |V30 |V31 |V32 |V33 |V34 |V35 |V36 |V37 |V38 |V39 |V40 |V41 |V42 |V43 |V44 |V45 |V46 |V47 |V48 |V49 |V50 |V51 |V52 |V53 |V54 |V55 |V56 |V57 |V58 |V59 |V60 |V61 |V62 |V63 |V64 |V65 |V66 |V67 |V68 |V69 |V70 |V71 |V72 |
+|:--|:--|:--|:--|:--|:--|:--|:--|:--|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|:---|
+^D
+| V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9 | V10 | V11 | V12 | V13 | V14 | V15 | V16 | V17 | V18 | V19 | V20 | V21 | V22 | V23 | V24 | V25 | V26 | V27 | V28 | V29 | V30 | V31 | V32 | V33 | V34 | V35 | V36 | V37 | V38 | V39 | V40 | V41 | V42 | V43 | V44 | V45 | V46 | V47 | V48 | V49 | V50 | V51 | V52 | V53 | V54 | V55 | V56 | V57 | V58 | V59 | V60 | V61 | V62 | V63 | V64 | V65 | V66 | V67 | V68 | V69 | V70 | V71 | V72 |
+|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|
+```