From 65d79295eceb8f8f63da9062b13bfb6dff5029c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Fri, 9 Oct 2026 06:38:35 -0400 Subject: [PATCH] ElyMark: short table rows compare padded, as GFM reads them (R2.13) --- apps/ely-mark/web/src/tables.js | 7 ++++++- tests/scripts/mark-session.sh | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/ely-mark/web/src/tables.js b/apps/ely-mark/web/src/tables.js index 2693483..0563a67 100644 --- a/apps/ely-mark/web/src/tables.js +++ b/apps/ely-mark/web/src/tables.js @@ -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)}` } diff --git a/tests/scripts/mark-session.sh b/tests/scripts/mark-session.sh index 0b03f59..f3d11ae 100755 --- a/tests/scripts/mark-session.sh +++ b/tests/scripts/mark-session.sh @@ -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.