DEV Community

Cover image for My DOCX converter treated redlines as final — in a contract, tracked changes are the negotiation
InApp
InApp

Posted on Originally published at imapp.blogspot.com

My DOCX converter treated redlines as final — in a contract, tracked changes are the negotiation

Last week a pipeline I run ingested a services agreement that had been through two rounds of redlining. My converter produced a spotless document — clean headings, numbered clauses, signature block. Spotless was the problem. Opening the original showed tracked changes everywhere: struck clauses, inserted terms, author initials in the margin. What my converter had actually done was silently apply every change — presenting a contested draft as if the deal were settled.

The mechanism is sneaky. In DOCX, text lives in <w:t> runs. When someone deletes text with track changes on, Word doesn't remove it — it wraps the run in <w:del> and retags it as <w:delText>. Insertions get wrapped in <w:ins> but keep normal runs. So a text extractor that walks the XML and reads every <w:t> drops deleted text (that's <w:delText>, not <w:t>) and keeps inserted text — which is exactly Word's "accept all changes", executed without anyone asking. Worse: <w:del> can also wrap a paragraph mark, and accepting it merges two paragraphs. Even your paragraph boundaries depend on a decision nobody made.

For most documents this is harmless. For contracts it changes meaning: an inserted clause is still an offer, not an agreement. My markdown handed a reviewer text that looked mutually accepted.

The fix was making acceptance explicit. I ended up adding three modes to my DOCX-to-Markdown converter (https://x402.freeq.one/tools/docx_to_markdown.html) — accept, reject, and annotate — with annotate as default: deletions rendered strikethrough, insertions flagged inline, margin comments appended under the paragraph they belong to. The pipeline now also greps the raw XML for w:del/w:ins before trusting any extraction and warns on contact.

The general lesson for agents: any DOCX that passed through human negotiation is not one document, it's two — the original and the "accept all" version — and summarizing the wrong one flips conclusions. Check for revisions before a redlined contract goes anywhere near a RAG index.

Top comments (0)