Turned Word formatting into clean HTML tags on upload for a regional legal publisher
Client snapshot
A small legal and regulatory publisher in Leeds with five editors. Authors send manuscripts as Word files, and the publisher's web platform only keeps formatting if it arrives as HTML tags inside the text.
The problem
Before every upload an editor went through the manuscript by hand and typed tags around bold, italic, underlined and struck-through text, plus the subscript and superscript markers used in citations and footnotes. A 40-page manuscript took around three hours, and a typical file still had about a dozen missed or unclosed tags that showed up as broken text on the live site.
What we built
- An upload page. A simple Streamlit page where an editor drops in a .docx file and downloads the converted file a few seconds later. No installs on the editors' laptops.
- Run by run parsing. A Python script reads every paragraph, table cell, header, footer and footnote with python-docx and looks at each text run's formatting.
- Merged runs first. Word often splits one formatted phrase into several runs. The script merges neighbouring runs with the same formatting before tagging, so one italic phrase gets one pair of tags, not five.
- Correct nesting. Bold inside italic, or superscript inside bold, is opened and closed in a fixed order, and existing angle brackets and ampersands are escaped so the platform never misreads them.
- Everything else untouched. The output is a new .docx with the same paragraphs, styles and tables, and only the formatted text replaced by tagged plain text.
- Checked against real examples. We ran it on twenty past manuscripts and compared the output against the editors' hand-tagged versions before handover.
Results, 30 days in
- Time to tag a 40-page manuscript: about three hours to under a minute.
- Missed or broken tags per manuscript: about twelve to none found in the first month.
- All six formatting types handled: bold, italic, underline, strike-through, subscript and superscript.
Quote
"The editors read for content again instead of hunting for italics." Managing editor
Build snapshot
- Timeline: 2 to 3 business days
- Stack: Python, python-docx, Streamlit, Microsoft Word
- Investment: $2,200
- Who owned it: the managing editor owns the tag mapping and the test manuscripts.
The pattern
Most formatting loss happens when a person retypes structure that the file already contains. Read the document's own formatting run by run, merge what Word split apart, map each style to one tag, and the conversion becomes a button instead of an afternoon. See the Document Sorter service.
This is an illustrative composite drawn from operator engagements. Names, identifying details, and exact metrics are anonymised. The workflow, stack, and approach are real.
Looks like your situation?
A 30-minute call tells us whether the same pattern fits your operation, and what it would cost to ship it.