Make markdownToAdf(adfToMarkdown(doc)) deep-equal doc #156

Merged
lilleman merged 67 commits from deep-equal-round-trip into main 2026-10-03 17:56:46 +02:00
Showing only changes of commit 31576bb824 - Show all commits
+2 -2
View File
@@ -54,9 +54,9 @@ export function reduceToPlain(document: AdfDocument): Result<AdfDocument> {
// docs/decisions.md §Equality is deep: the reduction reads and writes editor-normal ADF. // docs/decisions.md §Equality is deep: the reduction reads and writes editor-normal ADF.
const blocks = reduceBlocks(nodeContent(toEditorNormal(document)), { depth: 0, memo: new Map(), path: [] }) const blocks = reduceBlocks(nodeContent(toEditorNormal(document)), { depth: 0, memo: new Map(), path: [] })
if (!blocks.ok) { if (!blocks.ok) {
// Merging text renumbers siblings, so the caller's document names the refusal's path. // Merging text renumbers siblings, so the caller's document names the path of the refusal the editor-normal one meets.
const raw = reduceBlocks(nodeContent(document), { depth: 0, memo: new Map(), path: [] }) const raw = reduceBlocks(nodeContent(document), { depth: 0, memo: new Map(), path: [] })
return raw.ok ? blocks : raw return !raw.ok && raw.error.code === blocks.error.code ? raw : blocks
} }
return success({ content: nodeContent(toEditorNormal({ content: blocks.value, type: 'doc', version: 1 })).slice(), type: 'doc', version: 1 }) return success({ content: nodeContent(toEditorNormal({ content: blocks.value, type: 'doc', version: 1 })).slice(), type: 'doc', version: 1 })
} }