mtplatx-doc-diff
Semantic tree diff: Document → Patch<Operation>, replayable.
The diff engine compares two Documents at the semantic level — never at
the source-text level — and emits an ordered Patch of Operations that can
be replayed to transform old into new. The implementation is a Myers-style
block LCS over top-level blocks; nested structures (lists, tables, quotes)
re-run the same algorithm over their child vectors.
Example
use ;
use ;
let mut before = new;
before.push;
before.push;
let mut after = before.clone;
after.blocks = heading;
after.push;
let patch = diff;
let stats = from;
println!;
for op in &patch.operations
// Replay: apply(before, &patch) == after
let replayed = apply.unwrap;
assert_eq!;
API
diff(&Document, &Document) -> Patch— semantic block-level diffapply(Document, &Patch) -> Result<Document, DiffError>— replay the patchOperation—Insert,Delete,Replace,Move,UpdateMetadata(serde-taggedop)Patch—operations,len(),is_empty(),edit_distance()DiffStats—From<&Patch>summary counters
License
Licensed under the MIT License (see the license field in Cargo.toml).
Part of the Mtplatx document engine.