Why .docx-specific handling matters
Even though .docx is XML under the hood, the way Word emits it is messy: a single bold word can be split across three runs because the cursor moved between keystrokes. A naive converter produces output like **Hello** **wo** **rld**. We coalesce adjacent runs that share styling, normalise smart-quotes and non-breaking spaces, and strip the empty paragraphs Word inserts when you press Enter twice.
What gets preserved
Heading levels (Heading 1 → #, Heading 2 → ##, etc.), ordered and unordered lists with nesting, bold/italic/strikethrough, hyperlinks with their text labels, simple tables, footnotes, code-styled runs (Word's "Code" character style → backtick spans). Track Changes, comments, and revision marks are resolved to the final accepted text — see word-with-track-changes-to-markdown for fine-grained control.