cd /news/ai-tools/my-docx-converter-quoted-a-contract-… · home › topics › ai-tools › article
[ARTICLE · art-143533] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=· neutral

My DOCX converter quoted a contract clause the reviewer had already deleted — tracked changes hide in the file

A developer found that their DOCX-to-Markdown converter and RAG pipeline were quoting deleted contract clauses because unaccepted Word tracked changes persist in word/document.xml as <w:del>/<w:delText> elements. One 14-page contract returned roughly 2,100 extra words — about 9% of the total — of rejected language. The fix classifies <w:del> as document-history metadata to drop, unwraps <w:ins>, and adds an accept_revisions option that strips revisions by default with an opt-in redline mode.

by read2 min views1 publishedOct 1, 2026

An agent using my document pipeline answered a question about a vendor contract with clause numbers that didn't exist. The clause had been struck out during review — but the RAG index still had it.

I pulled the DOCX apart. Word documents are zip archives, and tracked changes live in word/document.xml as first-class citizens: insertions are wrapped in <w:ins>, deletions in <w:del>, and deleted text sits in its own element type, <w:delText>. Critically, an unaccepted revision stays in the file forever — nothing removes it until someone clicks Accept in Word.

My converter's text walker collected every text-ish node. Since <w:delText> quacks like a text node, out it came, interleaved with the surviving text. One 14-page contract came back with roughly 2,100 extra words — about 9% of the total — and all of it was language that had been rejected.

The fix was less deleting and more classifying:

<w:del> (including <w:delText> runs) is metadata about the document's history, not its content. Drop it.<w:ins> wrappers can simply be unwrapped — the text inside is live, just tagged.<w:moveFrom>/<w:moveTo> pairs from drag-edits, and <w:rPrChange>, which is formatting-only noise that still bloats the XML if you do anything naive like regex over the raw file. I also added an accept_revisions option: on gives you the document "as if everyone clicked Accept"; off keeps strikethrough text visible for tools that genuinely want a redline. Default is stripped, because a retrieval pipeline has no business quoting text a lawyer deleted.

The lesson generalizes: document files are databases of editorial intent, and "visible in Word" is not the same as "part of the document." If your pipeline ingests contracts or redlined drafts, check whether deleted clause text survives a round trip.

I folded all of this into my DOCX-to-Markdown converter (https://x402.freeq.one/tools/docx_to_markdown.html) — revisions stripped by default, redline mode if you explicitly ask for it.

── more in #ai-tools 4 stories · sorted by recency
── more on @word 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/my-docx-converter-qu…] indexed:0 read:2min 2026-10-01 · —