Skip to content

Commit 09ce24d

Browse files
raifdmuellerclaude
andcommitted
fix: Pad incomplete last table row with empty cells
When allCells.length % colCount !== 0, the last row would have fewer columns than the header, producing an invalid Markdown table. Pad with empty strings to always produce a rectangular table. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d8ecf2c commit 09ce24d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

scripts/generate-llms-txt.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ function convertAdocTable(body) {
5151
}
5252
if (colCount <= 0) colCount = 2
5353

54-
// Group cells into rows
54+
// Group cells into rows, padding incomplete last row with empty cells
5555
const rows = []
5656
for (let i = 0; i < allCells.length; i += colCount) {
57-
rows.push(allCells.slice(i, i + colCount))
57+
const row = allCells.slice(i, i + colCount)
58+
while (row.length < colCount) row.push('')
59+
rows.push(row)
5860
}
5961

6062
if (rows.length === 0) return ''

0 commit comments

Comments
 (0)