DOCX Parsing
A .docx file is fundamentally a zip archive containing XML files. Rendering it in the browser involves unzipping the blob in-memory and semantically mapping Word's proprietary XML schema to standard HTML.
Semantic Conversion Strategy
Unlike PDFs which mandate pixel-perfect coordinate layouts, Word documents flow. Our approach prioritizes semantic fidelity over visual perfection. We use a tailored implementation of mammoth.js.
Mammoth ignores extraneous formatting (like exact font sizes or obscure margin adjustments) and maps Word styles directly to HTML equivalents:
| Word Style | HTML Output |
|---|---|
| Heading 1 | <h1> |
| Normal | <p> |
| List Paragraph | <ul><li> |
| Emphasis | <em> |
Handling Embedded Media
Images embedded within the DOCX archive (found in the word/media/ directory of the zip) are extracted as raw binary strings and converted to data:image/*;base64 URIs. This allows them to render immediately in the DOM without requiring a temporary server host.
Complex vector shapes (VML) and highly customized SmartArt graphics are currently dropped during parsing to prevent DOM pollution and memory leaks.