md-to-word
Compiles Markdown manuscripts into deterministic, standards-compliant Word (.docx) documents, handling headings, tables, native OMML equations, figures with captions, TOC/section/page-break markers, and bibliography citations, with validation and line-numbered error diagnostics before export.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
md-to-word
把 Markdown 确定性编译为规范 Word(.docx)。专为学位论文、技术报告、学术论文与公文排版打造,也是面向 AI Agent 设计的确定性排版引擎。
解决通用工具导出 Word 时的格式漂移、公式无法二次编辑、三线表跨页无表头、无法独立分节分页码等问题。内容写在 Markdown 中,格式规则写在纯文本 format.txt 里,随稿件进 Git 版本管理。
成品效果
以下为实际导出的 Word 样张(由生成的 PDF 真实渲染,非示意图,在线样张页 可直接下载 .docx 成品核对):
最小起步样例一页纸最短路径 | 中文学位论文目录域 / 罗马页码 / 章名双线页眉 | 现代技术报告全网格表 / 引用块 / 彩色标题 | 英文期刊投稿APA 作者-年份制 / 交叉引用 |
💡 另含繁体中文期刊样例(
demo/04_zh_tw_paper),5 套样张的完整源码与格式文件详见 demo/ 目录。
快速开始
根据你的使用习惯选择接入方式:
1. 终端命令行(CLI)
纯 Python 实现,不依赖 Pandoc、Quarto 或 Office:
# 1. 安装核心编译器
pip install md-to-word-docx
# 2. 初始化示例文件(写入 format.txt 与示例稿件)
md-to-word init
# 3. 编译导出
md-to-word hello.md -f format.txt -o hello.docx
# (可选)没有格式文件时,使用内置学术预设快速出稿
md-to-word hello.md --preset zh-academic -o hello.docx2. AI 智能体(Claude Code / 终端 Agent)
作为 Agent Skill 接入,让 AI 按照规范排版并根据行号门禁自我修正:
# 通过 npx 直接安装技能
npx skills add ls-open/md-to-word说明:若已集成 Nature Skills,直接对 AI 说“把论文导出为 Word”或“按学校规范排版”即可由 Agent 自动调度触发。
3. 桌面端 MCP(Claude Desktop / Cursor)
在客户端的 mcpServers 配置中添加(使用 uvx 自动隔离运行,无需手动配环境):
{
"mcpServers": {
"md-to-word": {
"command": "uvx",
"args": ["--from", "md-to-word-docx[mcp]", "md-to-word-mcp"]
}
}
}核心特性
Word 原生数学公式:输出原生 OMML 矢量公式(Word 中双击可二次编辑,非位图),公式绝对居中、编号精准靠右对齐,支持
@eq-交叉引用。学术三线表:边框线宽精准可控,长表格跨页自动重复表头。
独立分节与页码:支持前置页罗马页码(
i, ii)、正文阿拉伯页码(1, 2)独立计数,生成 Word 原生动态目录域(按 F9 刷新)与随章变换页眉。29 套 CSL 参考文献:内置国标 GB/T 7714、Nature、IEEE、APA 等常用样式,由
.bib自动生成引文列表。带精确行号的双向门禁:导前语法预检、导后防丢数核对、底模 XML 样式对账。格式不合规时带行号报错中止,方便人类与 AI Agent 定位修改。
同一平台逐字节一致:固定时间戳、权限与打包顺序,相同源文件在同系统下重复编译产物二进制完全一致,便于 Git 差异比对。
现成 Word 模板支持
反推格式声明:从已有
.docx模板反推format.txt:md-to-word-template 模板.docx -o format.txt正文灌入底模:原样保留学校或单位模板的封面与授权书:
md-to-word 论文.md -f format.txt --base-template 模板.docx --keep-until 版权使用授权书 -o 论文.docx
常用写法速查
结构 | Markdown 语法 | 说明 |
段落样式 |
| 行首 |
编号公式 |
| 独立成行;正文使用 |
图表题注 | 表前 | 题注与图表同页绑定,换页不分离 |
参考文献 | 正文 | 文献表按 CSL 样式自动渲染 |
结构标记 |
| 目录域、分节换页码;各自独立成行 |
完整词表与规范详见使用手册,亦可运行
md-to-word --contract打印。
已知局限
逐字节一致限同平台:跨平台受系统底层 zlib deflate 压缩实现差异影响,二进制会略有不同。
不便支持的复杂版式:受 Markdown 与单栏样式模型所限,暂不支持单元格合并、斜线表头、多栏混排及文字环绕浮动图。
PDF 导出:
--pdf展开目录域依赖 macOS 系统的 Word 环境;无 Word 环境时跳过 PDF,.docx正常生成。
协同生态
Nature Skills:科研论文全流程写作 Agent 技能集。本项目的技能版已合并入该仓库(即
nature-paper2word技能),负责终稿阶段的规范 Word 编译交付。Academic Research Skills:由五个研究技能组成、采用十阶段流水线的学术研究框架。本项目被收录在其第三方项目列表中,在 Stage 5(FINALIZE)产出 Markdown 草稿与参考文献后,直接承接出规范
.docx。中文独立开发者:收录于程序员专刊精选独立项目。
许可
MIT License。内置 CSL 样式来自 citation-style-language/styles(CC BY-SA 3.0)。
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Turn Markdown and AI answers into Word (.docx) with native equations, or into PDF.
Use your own Word templates to convert Markdown → DOCX/PDF/HTML from any MCP-compatible AI.
Generate PDF, Word (.docx) and PowerPoint (.pptx) documents from Markdown over MCP.
Create Word .docx files from sections or markdown, fill templates, and read text from a .docx.
Related MCP Servers
- AlicenseAqualityDmaintenanceConverts Markdown documents to professional Word documents with advanced formatting capabilities including mathematical formulas, custom styling, tables, images, headers/footers, and watermarks.486 npm14MIT
- AlicenseBqualityDmaintenanceEnables creating professional Word documents from markdown or structured content with fast, customized formatting via natural language.71ISC
- AlicenseNot gradedqualityBmaintenanceConverts DOCX/XLSX to Markdown with native OOXML chart-data extraction (reads numCache/strCache directly, no OCR or rasterization) and zero-loss composite-figure markers. Ships a CLI, an MCP server (stdio + Streamable HTTP), and an optional VLM fallback for figures with no native chart data.61 PyPIApache 2.0
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to convert GitHub Flavored Markdown into formatted Word (.docx) files, including headings, lists, tables, links, code and images, with an optional Chinese official document (公文) font preset. Conversion runs locally, so no content is uploaded.115 npm1MIT