Files
docmost-sync/test/fixtures/corpus/01-headings-paragraphs.json
vvzvlad 4b34f4d30a 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
2026-06-16 23:23:32 +03:00

37 lines
908 B
JSON

{
"type": "doc",
"content": [
{
"type": "heading",
"attrs": { "level": 1 },
"content": [{ "type": "text", "text": "Level one heading" }]
},
{
"type": "paragraph",
"content": [{ "type": "text", "text": "A plain paragraph of text." }]
},
{
"type": "heading",
"attrs": { "level": 2 },
"content": [{ "type": "text", "text": "Level two heading" }]
},
{
"type": "paragraph",
"content": [
{ "type": "text", "text": "First line of a paragraph" },
{ "type": "hardBreak" },
{ "type": "text", "text": "second line after a hard break." }
]
},
{
"type": "heading",
"attrs": { "level": 3 },
"content": [{ "type": "text", "text": "Level three heading" }]
},
{
"type": "paragraph",
"content": [{ "type": "text", "text": "Closing paragraph." }]
}
]
}