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)}`
}
+1
View File
@@ -131,6 +131,7 @@ check quoted.md $'> |alpha|beta|\n> |---|---|\n> |1|2|\n' 'keystroke "x"' $'> |x
check listed.md $'- item\n\n |alpha|beta|\n |---|---|\n |1|2|\n' 'keystroke "x"' $'- xitem\n\n |alpha|beta|\n |-|-|\n |1|2|\n'
# Items open with a paragraph; a leading table stays raw.
check leading.md $'- |alpha|beta|\n |---|---|\n' 'keystroke "x"' $'x- |alpha|beta|\n |---|---|\n'
check short.md $'|a|b|c|\n|-|-|-|\n|1|2|\n' 'keystroke "x"' $'|xa|b|c|\n|-|-|-|\n|1|2||\n'
# Cells Milkdown would rewrite keep the table raw.
check wikicell.md $'|a|[[Wiki Link]]|\n|-|-|\n|1|2|\n' 'keystroke "x"' $'x|a|[[Wiki Link]]|\n|-|-|\n|1|2|\n'
# Deleting forward at a hidden definition moves nothing.