aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-05-17 09:59:17 -0700
committerJohn MacFarlane <[email protected]>2025-05-17 09:59:17 -0700
commitfbeadcd0baae29decc19d2ac42d8a40fc974b868 (patch)
tree5e5dfb281d31c8d32873cb310df69cccb1a50ea3
parentcc4ccb07e39a90dc0ebcf87e50e95c9abfe62499 (diff)
gridTables: properly handle columns with all empty cells.
See #10848.
-rw-r--r--src/Text/Pandoc/Writers/Shared.hs6
-rw-r--r--test/command/10848.md23
2 files changed, 25 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs
index 4c7baad1c..1cb3046d3 100644
--- a/src/Text/Pandoc/Writers/Shared.hs
+++ b/src/Text/Pandoc/Writers/Shared.hs
@@ -325,7 +325,7 @@ extractColWidths opts rows = (currentwidths, fullwidths, minwidths)
getCellWidths calcOffset c = replicate (cellColSpan c)
(calcOffset c `div` (cellColSpan c) +
calcOffset c `rem` (cellColSpan c))
- fullwidths = getWidths (offset . cellContents)
+ fullwidths = getWidths (max 1 . offset . cellContents)
currentwidths = getWidths cellWidth
minwidths =
case writerWrapText opts of
@@ -430,9 +430,7 @@ gridRows (x:xs) =
-- be interpreted as an indented code block...even though it
-- would look better to right-align right-aligned cells...
-- (TODO: change this on parsing side?)
- lblock (case cellWidth c of
- 0 -> 16 -- TODO arbitrary
- w -> w) (cellContents c)
+ lblock (cellWidth c) (cellContents c)
formatRow cs = vfill "| " <>
hcat (intersperse (vfill " | ") (map renderCellContents cs)) <> vfill " |"
diff --git a/test/command/10848.md b/test/command/10848.md
index 5ac700103..102febab4 100644
--- a/test/command/10848.md
+++ b/test/command/10848.md
@@ -57,3 +57,26 @@
| | K |
+---+---------------+
```
+
+```
+% pandoc -f html -t markdown-simple_tables-multiline_tables-pipe_tables
+<table>
+ <tbody>
+ <tr>
+ <td>a</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+^D
++---+---+
+| a | |
++---+---+
+| | |
++---+---+
+```
+