Skip to content

Commit fbeadcd

Browse files
committed
gridTables: properly handle columns with all empty cells.
See #10848.
1 parent cc4ccb0 commit fbeadcd

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/Text/Pandoc/Writers/Shared.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ extractColWidths opts rows = (currentwidths, fullwidths, minwidths)
325325
getCellWidths calcOffset c = replicate (cellColSpan c)
326326
(calcOffset c `div` (cellColSpan c) +
327327
calcOffset c `rem` (cellColSpan c))
328-
fullwidths = getWidths (offset . cellContents)
328+
fullwidths = getWidths (max 1 . offset . cellContents)
329329
currentwidths = getWidths cellWidth
330330
minwidths =
331331
case writerWrapText opts of
@@ -430,9 +430,7 @@ gridRows (x:xs) =
430430
-- be interpreted as an indented code block...even though it
431431
-- would look better to right-align right-aligned cells...
432432
-- (TODO: change this on parsing side?)
433-
lblock (case cellWidth c of
434-
0 -> 16 -- TODO arbitrary
435-
w -> w) (cellContents c)
433+
lblock (cellWidth c) (cellContents c)
436434

437435
formatRow cs = vfill "| " <>
438436
hcat (intersperse (vfill " | ") (map renderCellContents cs)) <> vfill " |"

test/command/10848.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,26 @@
5757
| | K |
5858
+---+---------------+
5959
```
60+
61+
```
62+
% pandoc -f html -t markdown-simple_tables-multiline_tables-pipe_tables
63+
<table>
64+
<tbody>
65+
<tr>
66+
<td>a</td>
67+
<td></td>
68+
</tr>
69+
<tr>
70+
<td></td>
71+
<td></td>
72+
</tr>
73+
</tbody>
74+
</table>
75+
^D
76+
+---+---+
77+
| a | |
78+
+---+---+
79+
| | |
80+
+---+---+
81+
```
82+

0 commit comments

Comments
 (0)