Skip to content

Commit

Permalink
fix: ensure that rowspan is bound to table limits (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
tripodsan authored Feb 25, 2025
1 parent f41b4a5 commit 3195c5d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/to-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ class Table {
if (cell.tree) {
realNumCols = Math.max(realNumCols, x + 1);
}
// ensure rowspan is not too large
cell.rowSpan = Math.min(cell.rowSpan, this.rows.length - y);
if (cell.rowSpan > 1) {
// insert colspan amount of null cells below
for (let i = 1; i < cell.rowSpan; i += 1) {
Expand Down
2 changes: 1 addition & 1 deletion test/gridtable-to-md.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ describe('gridtable to md', () => {
cell(text('B7'), 1, 1),
]),
gtRow([
cell(text('AB8'), 1, 2),
cell(text('AB8'), 2, 2),
]),
]),
heading(2, text('Table with overlapping spans')),
Expand Down

0 comments on commit 3195c5d

Please sign in to comment.