Install
openclaw skills install md-to-docxConvert Markdown files to formatted Word (.docx) documents with automatic template style detection. Use this skill whenever the user mentions converting Markdown to Word, exporting to .docx, generating a Word document from .md files, applying a Word template to Markdown content, or writing a book chapter to Word format. Also use when the user needs to handle Mermaid diagrams in Word documents, or wants Chinese typesetting conventions (宋体/黑体, 五号字, 首行缩进) applied to their output. Triggers on phrases like "转成 word", "导出 docx", "生成 Word 文档", "用模板排版", "Markdown to Word", "book to Word", "chapter to docx", or any request involving .md → .docx conversion.
openclaw skills install md-to-docxConvert Markdown files to professionally formatted Word documents, with automatic template style extraction and Mermaid diagram rendering.
The bundled script (scripts/md_to_docx.py) handles the entire conversion:
mmdc (mermaid-cli) and embed them as imagesThe script requires:
pip install python-docxnpm install -g @mermaid-js/mermaid-cliOn macOS, .doc templates are converted via the built-in textutil. On Linux, LibreOffice is used as fallback.
python3 scripts/md_to_docx.py input.md -o output.docx
python3 scripts/md_to_docx.py input.md -o output.docx -t template.doc
When the user asks to convert a Markdown file to Word:
.md file path.doc/.docx template, or check if one exists in common locations (docs/, templates/)pip3 install python-docx
npm list -g @mermaid-js/mermaid-cli 2>/dev/null || npm install -g @mermaid-js/mermaid-cli
scripts/ directory:
python3 <skill-path>/scripts/md_to_docx.py <input.md> -o <output.docx> [-t <template.doc>]
When a template is provided, the script analyzes it automatically:
If no template is provided, these defaults are used (Chinese publishing standard):
| Element | Font | Size | Alignment |
|---|---|---|---|
| Chapter title (h1) | 黑体 | 18pt | Center |
| Section title (h2) | 黑体 | 16pt | Center |
| Subsection (h3) | 黑体 | 14pt | Left |
| Body text | 宋体 | 10.5pt (五号) | Justify, 2-char indent |
| Code | Consolas | 9pt | Left |
| Quote | 楷体 | 10.5pt | Left indent, italic |
code, - or *) and ordered lists (1.)Mermaid code blocks are rendered to PNG via mmdc using the local Chrome browser. If rendering fails (e.g., Chrome not found, syntax error), the diagram falls back to a code block display.
Common Mermaid compatibility fixes are applied automatically:
subgraph names containing colons are quoted/Applications/Google Chrome.app/...Program Files and LocalAppData/usr/bin/google-chrome, /usr/bin/chromium, /snap/bin/chromium.doc conversion: Uses textutil on macOS, libreoffice on Linux