docxCompareVersions: tracked-changes redline between DOCX versions

↗ view on GitHub · Eli Ziff · 2026-07-28 · ea39e713

compareDocxVersions(oldBytes, newBytes) marks the NEW document with
w:ins/w:del so Word's accept/reject round-trips both versions: block
alignment by normalized text (prefix/suffix trim + LCS, capped with a
typed whole-comparison abstention), gap pairing by edit-distance with a
similarity floor, then word-level clusters whose tokenizer mirrors the
reference implementation's quote_edits.py (word tokens with internal
apostrophes, punctuation separate, zero-gap merge, quote/dash/whitespace
equivalence - case folding deliberately dropped: case changes are real
redline content). Emission grammar, zip access, and normalization reuse
the existing docxTrackedChanges/zip/text machinery.

Everything the diff cannot honestly represent abstains with a stable
typed code (tables, content controls, headers/footers/notes, fields,
hyperlinks, pre-existing revisions, numbering changes, unrepresentable
deletions) and leaves the new version's content unmarked. 6 fixture
tests with raw-XML assertions; suite green; tsc clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018bhP89cYSdEEjHNPnxacns
Repository eliziff/Beaver
Author Eli Ziff <eliasziff@gmail.com>
Authored
Parents 18cba572
Stats 2 files changed , +2139
Part of SourceDoc / DOCX engine: redlines, tracked changes, editing benchmark

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-ea39e713.md from inside the repo you want the change in.

⬇ Download capture-commit-ea39e713.md