skills/markdown2docx/SKILL.md
Convert Markdown files to professional .docx documents with Chinese formatting, table styling, automatic TOC, headers/footers, and page layout control. Use this skill whenever the user wants to turn a .md file into a Word document, especially for software requirement specifications, technical reports, requirements documents, or any structured Chinese document. Triggers include: "convert md to docx", "md转docx", "markdown to word", "生成word文档", "导出docx", "make a word doc from markdown".
npx skillsauth add kit101/skillz markdown2docxInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
将 Markdown 文件转换为格式良好的 .docx 文档。规则化的排版通过 YAML 配置 + 脚本自动处理,需要人工判断的决策由 LLM 完成。
# 默认配置
python scripts/build.py input.md
# 软件需求规格 文档配置
python scripts/build.py input.md assets/config.srs.yaml --output SRS.docx
# 自定义配置(用 --output 指定输出路径;或用 YAML 的 output 字段控制)
python scripts/build.py input.md my-config.yaml --output report.docx
构建中间产物保留在 {输出文件名}.docx-build/ 目录下(与输出 .docx 同名),方便手动修改 XML:
SRS.docx-build/
├── config.yaml # ← 用户自定义配置(LLM 直接在此生成)
├── input.md # 预处理后的 markdown
├── diagram_00.png # 渲染的 Mermaid 图片
├── reference.docx # 参考模板
├── draft.docx # pandoc 原始输出
├── config.json # 合并后的配置
├── build_ref.js # 参考模板构建脚本
└── unpacked/ # 解包后的 XML(可直接编辑)
├── [Content_Types].xml
└── word/
├── document.xml
├── styles.xml
└── ...
Markdown ──→ [render_mermaid] ──→ [pandoc + reference.docx] ──→ [XML post-process] ──→ .docx
↑ 脚本自动 ↑ 按 config 自动 ↑ 按 config 自动
├─ 样式修正
├─ 表格列宽缩放
├─ 代码块美化
└─ 边框/边距
脚本负责所有确定性操作,LLM 负责以下决策点。
根据文档类型选择或创建配置:
| 文档类型 | 推荐配置 |
|----------|----------|
| SRS | assets/config.srs.yaml |
| 通用技术文档 | 基于 assets/config.default.yaml 调整 |
⚠️ 配置文件位置:自定义配置必须直接写入 {输出文件名}.docx-build/config.yaml(与输出 .docx 同名目录),不要放在源文件目录。步骤:
mkdir -p doc/输出文件名.docx-build
# 然后 write 配置文件到 doc/输出文件名.docx-build/config.yaml
# 然后 build.py 指向该文件
需要 LLM 判断的配置项:
tables.small_table_indices:哪些表不需要全宽(如封面信息表、简单键值表)
观察 Markdown 中哪些表格只有 2 列且内容简短,记录其 0-based 索引tables.column_strategy:列宽策略(content/auto/scale/none,默认 content)
content 按每列最长文字比例分配(推荐,解决键值表键列过宽问题)auto 让 Word 按内容自动适配tables.header_style:表头美化(shaded/bold/none,默认 none)header.text:页眉文字title:文档标题fonts.body.size:正文字号(一般五号=21,小四=24,四号=28)脚本自动调用 mermaid.ink API 将 ```mermaid 代码块渲染为 PNG。
如果外部网络不可用,设置 render_mermaid: false,图表将保留为代码块。
自动检测规则(build.py 第 2 步自动执行):
# 一级标题 → 自动提取为封面标题,所有标题层级上移:
## Heading → Word Heading 1### Subheading → Word Heading 2# → 用 config 中的 title(若未设置则无封面页)# → 打印警告,不自动上移,LLM 须询问用户哪个是封面标题LLM 必须在运行 build.py 前检查:读取 markdown,数一下 # 开头的行,若 ≥2 个,询问用户。
# 1 范围)→ auto_numbering: false# 范围)→ auto_numbering: true,由 pandoc 自动编号当输出不符合预期时,LLM 应使用 docx skill 的脚本解包检查:
python ../docx/scripts/office/unpack.py output.docx unpacked/
# 检查 word/styles.xml、word/document.xml 等
常见问题及修复方法:
config.fonts.headings 对比Compact 样式是否被继承链上的 firstLine 影响<w:tblPr> 子元素有严格顺序要求pack.py 输出会提示具体元素位置错误tables.borders.insideH 控制中间横线:
val: none → PDF 不可见,Word 中可通过「视图→表格虚框」辅助编辑val: dashed → 打印/PDF 中可见虚线val: single → 实线脚本默认将代码块渲染为:等宽字体(Courier New)+ 浅灰背景(#F5F5F5)+ 9pt 字号。如需调整,编辑 unpacked/word/styles.xml 中 SourceCode 和 VerbatimChar 样式,然后手动运行 pack:
python ../docx/scripts/office/pack.py SRS.docx-build/unpacked/ SRS.docx --original SRS.docx-build/draft.docx
通过 tables.column_strategy 配置,四种策略可选:
| 策略 | 效果 | 适用场景 |
|------|------|----------|
| content | 扫描每列最长 cell,按文字比例分配 | 默认推荐,95% 场景 |
| auto | 删除 cell width,Word 按内容自动适配 | 内容简单、不想干预时 |
| scale | 保留 pandoc 列宽比例,等比缩放 | 表头长度能代表列宽时 |
| none | 不做任何调整 | 调试或特殊需求 |
小表格(small_table_indices 中指定的)不受列宽策略影响。
完整配置项参见 assets/config.default.yaml(含注释)。关键配置组:
page: # 页面尺寸、边距 (DXA)
fonts: # body 和 headings 的字体、字号、颜色
paragraph: # 行距、首行缩进
title_page: # 标题页布局
toc: # 目录标题、层级深度、分页
header/footer: # 页眉页脚内容
tables: # 宽度策略、单元格边距、边框样式
build.py 内部执行七个步骤:
scripts/render_mermaid.py,将 ```mermaid 块替换为 ## → #(Word Heading 1)、### → ##(Word Heading 2)...reference.docxpandoc --reference-doc=reference.docx --toc 产生初始 .docxunpack.pyNormal/Compact 样式(含首行缩进)SourceCode 样式 → 等宽字体、浅灰背景、9ptpack.py,含 Schema 验证中间产物保留在 {文件名}.docx-build/,不会自动删除。
docx (npm install -g docx)md2docx/
├── SKILL.md ← 本文件
├── scripts/
│ ├── build.py ← 主编排脚本
│ └── render_mermaid.py ← Mermaid → PNG
└── assets/
├── config.default.yaml ← 默认配置(含注释)
└── config.srs.yaml ← 软件需求规格 示例配置
documentation
Convert academic papers, theses, and technical documents from .docx to clean Markdown with proper LaTeX formulas, equation numbering, figures, and tables. Triggers when the user mentions converting a .docx paper/thesis/document to Markdown, extracting formulas from Word to LaTeX, or cleaning up pandoc-generated Markdown with formula artifacts. Also trigger when user says "docx转md", "word转markdown", "论文转markdown", "公式转latex", or mentions pandoc output has broken/escaped formulas.
development
Convert Markdown files to PDF with Chinese formatting, LaTeX math formulas, and embedded images. Use this skill whenever the user wants to turn a .md file into a PDF document, especially when the Markdown contains Chinese text, math formulas ($$ or $), tables, or images. Triggers include:"md转pdf", "markdown to pdf", "导出pdf", "生成pdf", "convert md to pdf", "转为pdf", or when the user mentions a .md file and asks to make it a PDF.
development
Compare two markdown files and generate a structured changelog in open-source standard format (date-based versions, Summary/Added/Changed/Removed tables). Use whenever the user wants to compare .md file versions, create a changelog or release notes, document version differences, or mentions "changelog", "版本差异", "修订日志", "diff", "变更记录" in context of markdown files.
tools
SSL证书检查器是一个用于检查SSL证书有效期的agent技能,它可以检查指定域名的SSL证书是否即将过期,返回检查结果,使用mcp-email发送即将过期的警告邮件给订阅者。