gridTables: properly handle columns with all empty cells.

See #10848.
This commit is contained in:
John MacFarlane
2025-05-17 09:59:17 -07:00
parent cc4ccb07e3
commit fbeadcd0ba
2 changed files with 25 additions and 4 deletions
+2 -4
View File
@@ -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 " |"
+23
View File
@@ -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 | |
+---+---+
| | |
+---+---+
```