Repository navigation
Conversation
Word records a tracked equation edit inside each math run, <m:r><w:del …><m:t>x</m:t></w:del></m:r>, and documents it as supported (MS-OI29500, Part 1 §22.1.2.87 (e)), but ECMA-376's CT_R has no slot for it. So `docx validate` and the raw gate's baseline reported "del: This element is not expected" for every file Word saved with such an edit, including a docx-cli `<w:del><m:oMath>` edit once Word re-saved it (Word rewrites it to its own shape). validationXmlFor now unwraps those marks in its clone, next to the MCE pass; what they wrap is still checked against CT_R. The schemas stay as published.
|
🤖 docx-cli triage Thanks @xsvm, this is a clean, well-scoped fix. I reviewed head Claim: Before/after (minimal docx from
So the unwrap only touches the validation copy and only applies inside Checks: Docs: the Decisions for the maintainer
Action needed: approve/merge — PR #31 is ready as-is (I pushed nothing, so your own approval satisfies the last-push rule). Please also decide on the two checklist items above. Generated by Claude Code |
|
@xsvm hold off from making further changes till i've had a bit of time to read through and do my own reviews, it's gonna take me a few days. |
Summary
docx validaterejected every document Word saved with a tracked equation edit:Word records a tracked edit inside an equation per math run:
<m:r><w:del …><w:rPr>…</w:rPr><m:t>E</m:t></w:del></m:r>(one mark per run, plus one in eachm:ctrlPr). ECMA-376'sCT_Rhas no slot forw:ins/w:del, but Microsoft documents it as supported Word behavior: MS-OI29500, Part 1 §22.1.2.87 (e), "Word supports the w:ins and w:del elements inside a math run." (Them:ctrlPrmarks are already valid.)This also hits docx-cli's own edits.
equations edit --trackwrites<w:del><m:oMath>…</m:oMath></w:del><w:ins>…</w:ins>, which validates; once a user opens and saves that file in Word, Word rewrites it into the per-run shape above andvalidatereports 6 errors. Reproduced with Word 365 on Windows (open + SaveAs2 via COM). The same false errors land in the raw gate's baseline.The fix
validationXmlForalready preprocesses a clone (MCE strip) because real Word markup is valid OOXML the base schema doesn't know. It now also unwrapsw:ins/w:delthat sit directly inside anm:r, so what they wrap (m:rPr,w:rPr,m:t) is still validated againstCT_R. The schemas stay as published, persrc/core/raw/CLAUDE.md. Doc note added there.Related: #27's fixture uses this same Word shape, so it now passes
docx validatetoo.Test plan
bunx biome check .,bunx knip,bunx tsc --noEmittests/core/raw.test.ts: Word'sw:del/w:insinside a math run validate clean (failed before the fix); content inside the mark is still checked (a bogus element there is still reported)valid