
Md2word
This converts Markdown to professionally formatted Word documents with Chinese typography standards built in. It comes with presets for legal documents, academic papers, and reports, plus full configuration through YAML files. The tool handles encoding detection, auto-compresses oversized images, and degrades gracefully when Mermaid diagrams fail. It separates concerns nicely: Word templates control visual branding while config files handle formatting parameters like spacing and margins. The legal preset being default and the WeChat contact in the author field tell you exactly who built this and why.
- skills.sh installs
- 287
- GitHub stars
- 788
- last updated
- Aug 21, 2026
Install
$ npx -y skills add cat-xierluo/legal-skills --skill md2word --agent claude-codeInstalls into .claude/skills of the current project.
Files
Markdown转Word文档Skill
概述
将 Markdown 文档转换为符合中文排版标准的 Word 文档。支持完整的 Markdown 语法,自动应用专业格式设置。
依赖要求
Python 依赖
pip install python-docx Pillow beautifulsoup4 PyYAML
可选依赖
npm install -g @mermaid-js/mermaid-cli # Mermaid 图表渲染
brew install librsvg # SVG→PNG(推荐,rsvg-convert)
# 或 pip install cairosvg # SVG→PNG 备选
# 或 npm install puppeteer # SVG→PNG 备选(scripts/svg2png.js)
正文内联
<svg>...</svg>块会自动渲染为 PNG 嵌入,渲染优先级 rsvg-convert → cairosvg → svg2png.js(puppeteer),三者任一即可;全部不可用时降级为代码框显示 SVG 源码。
快速开始
主转换脚本:scripts/md2word.py
# 基本转换
python scripts/md2word.py input.md output.docx
# 使用预设格式
python scripts/md2word.py input.md --preset=academic
# 使用自定义配置
python scripts/md2word.py input.md --config=my-config.yaml
# 脚注/尾注模式(默认 footnote 页面脚注;endnote=文档末注释+上标编号)
python scripts/md2word.py input.md --notes=endnote
# 全书合并:多章 md → 单 docx(目录+按输入文件分章+页眉,配合 -o 指定输出)
python scripts/md2word.py --book ch01.md ch02.md ch03.md -o book.docx --preset=book-publish
Sponsors
Details
- Repository
- github.com/cat-xierluo/legal-skills
- Category
- Office & Documents
- First seen
- Jun 3, 2026