ElyMark: short table rows compare padded, as GFM reads them (R2.13)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-09 06:38:35 -04:00
1 parent 301890485f
commit 65d79295ec
2 files changed
+7 -1

No files matched your search

+6 -1
View File
@@ -22,7 +22,12 @@ export function canon(text) {
let out = text
// Later tables first, so earlier offsets hold.
for (const table of tables.reverse()) {
const rows = table.children.map((row) => row.children.map((node) => cell(text, node)).join('|'))
const width = table.children[0].children.length
// GFM fills a short row with empty cells.
const rows = table.children.map((row) => {
const cells = row.children.map((node) => cell(text, node))
return [...cells, ...Array(Math.max(0, width - cells.length)).fill('')].join('|')
})
const shape = [table.align.join(','), ...rows].join('\n')
out = `${out.slice(0, table.position.start.offset)}\u0000${shape}\u0000${out.slice(table.position.end.offset)}`
}