Export as Word (.docx)
A real Word document built from your Markdown. Headings as Word heading styles, native Word tables, images downloaded and embedded so the file is self-contained.
Word export builds a real .docx from your Markdown — not a wrapper around the source text. The result opens cleanly in Microsoft Word, Apple Pages, and Google Docs.
Kyoto, days 1-3
We land in Kyoto on the 12th and have three full days before Osaka.
| Day | Morning | Afternoon |
|---|---|---|
| Day 1 | Arashiyama | Tenryū-ji |
| Day 2 | Fushimi Inari | Nishiki |
How to export
Doc toolbar → download icon → Word (.docx). The browser downloads <title>.docx.
Under the hood
We use the docx JavaScript library, which builds a real Word XML document in the browser. The pipeline:
- Tokenize:
marked.lexer()parses your Markdown into a structured token tree - Walk: for each top-level token, build a
Paragraph(or set of paragraphs for lists, tables, etc.) - Inline tokens: bold, italic, strikethrough, code, links become
TextRunandExternalHyperlinkinstances - Images: each image URL is fetched as bytes, optionally normalized, then embedded as an
ImageRuninside the paragraph - Pack: the document tree gets serialized with
Packer.toBlob()and downloaded
The conversion is entirely client-side — no quota, no server call, works offline (except for the image fetches, which need network).
What survives the conversion
| Markdown | Word output |
|---|---|
| H1 through H6 | Word’s Heading 1 through Heading 6 styles |
| Title (synthesized if needed) | Heading 1 at the top |
| Paragraphs | Default style |
Bold, italic, code | Bold, italic, strikethrough, monospace runs |
| Links | Real Word hyperlinks with their target URL |
| Bullet lists, numbered lists | Word’s native list styles, nested levels preserved |
| Tables | Native Word tables with the header row marked |
| Blockquotes | Indented paragraphs (Word’s blockquote doesn’t exist as a distinct style) |
| Fenced code blocks | Single-spaced monospace paragraphs |
| Horizontal rules | Word’s horizontal rule paragraph |
| Images (with or without width / alignment) | Embedded ImageRun with the width and alignment carried through |
| Hex color swatches | The hex literal as text |
Image handling — self-contained
The big win over Markdown export: images are downloaded and embedded inside the .docx, not left as URL references. The file is self-contained — you can email it, archive it, or attach it to a ticket and the recipient sees the images even without internet access.
Each  becomes:
- A
fetch(url)to pull the image bytes - An
ImageRuninstance wrapping those bytes - A paragraph containing the image (with the width and alignment from the original)
If an image fetch fails (network error, CORS, image deleted), it’s skipped silently — the export proceeds without it.
What’s lost or transformed
| Markdown / sweetdocs feature | Word result |
|---|---|
| Sweetdocs theme colors | Replaced by Word’s default styling |
Inline HTML (other than <img>) | Dropped — only image HTML is interpreted by the converter |
| Comment anchor spans | Dropped (just the visible text remains) |
| Hex color swatches | Visible as text only; no color chip |
Live links between docs (/docs/...) | Kept as their literal URL |
| Code-block language hint | The hint is dropped at the Word level (Word doesn’t model fence languages); the content stays monospace |
When to use Word export
- The recipient lives in Word and you don’t want them to deal with Markdown
- You need a self-contained document with images embedded (archival, attachments)
- You’re shipping a formal document — Word’s defaults are familiar everywhere
- You want a paginated document with native heading-style navigation in Word’s outline panel
Compared to PDF
PDF and Word are both “produces a finished document” exports, but:
| Word | ||
|---|---|---|
| Recipient can edit | Yes | No (without OCR tools) |
| Heading navigation | Yes (Word’s outline) | Yes (PDF bookmarks, when supported) |
| File size | Larger (embedded images) | Varies (depends on image compression) |
| Exact visual reproduction | No (Word reflows) | Yes |
| Generation path | Client-side, instant | Through the browser print dialog |
Use Word when the document will be edited; use PDF when the document is final.