feat(sync): resolve §11 idempotency via canonical comparison + corpus harness
Close Задача №0 (SPEC §11) with the spec-sanctioned option (b): compare a canonicalized ProseMirror form instead of raw bytes. - canonicalize.ts: canonicalizeContent/docsCanonicallyEqual — strip node attrs.id, drop null/undefined attrs, and drop attrs equal to their type's known non-null schema default (KNOWN_DEFAULTS: link target/rel, comment.resolved, orderedList.start, diagram/media align) so "absent" ≡ "default"; comment anchors + meaningful attrs kept - roundtrip.ts: assert markdown byte-stability AND canonical stability; add --corpus mode and mutually-exclusive-flag warning - synthetic corpus (headings, marks, lists, table, callout, code w/ trailing \n, diagrams, textStyle/mention) + canonicalize/corpus tests (558 green) - known converter asymmetries (block image after paragraph; embed width/height coercion) converge to a fixpoint after one export->import pass -> handled by normalize-on-write at vault-write time; isolated under it.fails - SPEC §11: record the resolution and normalize-on-write strategy
This commit is contained in:
62
test/fixtures/corpus/02-inline-marks.json
vendored
Normal file
62
test/fixtures/corpus/02-inline-marks.json
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"type": "doc",
|
||||
"content": [
|
||||
{
|
||||
"type": "paragraph",
|
||||
"content": [
|
||||
{ "type": "text", "marks": [{ "type": "bold" }], "text": "bold" },
|
||||
{ "type": "text", "text": " " },
|
||||
{ "type": "text", "marks": [{ "type": "italic" }], "text": "italic" },
|
||||
{ "type": "text", "text": " " },
|
||||
{ "type": "text", "marks": [{ "type": "code" }], "text": "code" },
|
||||
{ "type": "text", "text": " " },
|
||||
{ "type": "text", "marks": [{ "type": "strike" }], "text": "strike" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "paragraph",
|
||||
"content": [
|
||||
{
|
||||
"type": "text",
|
||||
"marks": [
|
||||
{
|
||||
"type": "link",
|
||||
"attrs": {
|
||||
"href": "https://example.com/page"
|
||||
}
|
||||
}
|
||||
],
|
||||
"text": "a link"
|
||||
},
|
||||
{ "type": "text", "text": ", " },
|
||||
{
|
||||
"type": "text",
|
||||
"marks": [{ "type": "highlight" }],
|
||||
"text": "highlighted"
|
||||
},
|
||||
{ "type": "text", "text": ", base" },
|
||||
{ "type": "text", "marks": [{ "type": "subscript" }], "text": "sub" },
|
||||
{ "type": "text", "text": " and base" },
|
||||
{ "type": "text", "marks": [{ "type": "superscript" }], "text": "sup" },
|
||||
{ "type": "text", "text": "." }
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "paragraph",
|
||||
"content": [
|
||||
{ "type": "text", "text": "Here is a " },
|
||||
{
|
||||
"type": "text",
|
||||
"marks": [
|
||||
{
|
||||
"type": "comment",
|
||||
"attrs": { "commentId": "cmt-xyz789" }
|
||||
}
|
||||
],
|
||||
"text": "commented anchor span"
|
||||
},
|
||||
{ "type": "text", "text": " that must survive (SPEC §3)." }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user