md2docx-formal
Skill1 starsChanged 13 days agoMITView on GitHub
把 Markdown 转成规范排版的工程类中文 Word(.docx),用于投稿或归档。篇/章/节语义映射 H1–H5、A4 版面、宋体/黑体、1.5 倍行距、自动目录域、页眉页脚页码、GB/T 7714 顺序编码制上标引用(参考文献条目保持正常字号)。也可对已有 docx 做块级源文一致性审查。Triggers: md转word, markdown转docx, 转成Word, 排版Word, 论文转docx, 报告转Word, GB/T 7714, 一致性审查.
- Installs packages
In this repository30 other files it gives its agents.
- AGENTS.mdAGENTS.md
- notion-im-helper/CLAUDE.mdCLAUDE.md
- 3d-printing-cad-designSkill
- agent-skills-syncSkill
- captain-resourceSkill
- csdn-publish-mcpSkill
- deep-research-report-pipelineSkill
- doc-plain-zhSkill
- feishu-bot-configSkill
- first-shotSkill
- investment-analysisSkill
- layoutfixSkill
- md-to-70asunflower-latexSkill
- multi-publish-mcpSkill
- notebook-patchingSkill
- notion-im-helperSkill
- paper-figuresSkill
- paper-reviewSkill
- paper-writingSkill
- project-initSkill
- project-reviewSkill
- siyuan-backup-syncSkill
- siyuan-kernel-opsSkill
- siyuan-markdown-formula-formatterSkill
- snapSkill
- strict-docx-auditSkill
- trek-mcp-opsSkill
- visual-diagramsSkill
- weekreportSkill
- xhs-pipelineSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 115
Strict fidelity: Do not invent, add, or drop any text, data, or term.
- Very specific: line 119
Do not hand-edit the generated .docx to "fix" issues — manual Word edits corrupt eastAsia fonts and break fidelity with the source.
- Distinctive: line 126
After generation, report heading counts, table count, and the verify/audit summary to the user.
- Distinctive: line 128
If the source Markdown changes later, re-run step 1–3.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
md2docx-formal — Markdown → 规范 Word 工程文档
转完必须跑
strict-docx-audit技能做 12 项质检(字体、编号、上标、保真、 标题层级、表格、TOC、页面、eastAsia、空段),全部通过再交付。
Purpose
Turn a Chinese Markdown paper / report / thesis into a formally typeset .docx that meets
common submission/archive conventions, with 100% content fidelity (no fabrication, no
addition/deletion). The converter is python-docx based and reproducible: change the source
Markdown, re-run, re-verify.
When to use
- "把这份 md 转成正式 Word 文档 / 排个版"
- "内容更新了,重转 docx" / "重新生成 Word"
- "引用序号要上标" / "检查目录、页眉页脚、标题层级"
- Any task that maps a Markdown source to a typeset Chinese Word deliverable.
Script reference
Full script internals — functions, tunable constants, generic vs document-specific boundaries,
and the verification/audit logic — are documented in
references/script_reference.md. Read it before editing any
script so you don't break content fidelity.
Pre-flight check: ASCII 图(转换前必查)
扫描源 Markdown 的围栏代码块:若出现框线/箭头字符密集的内容(─│┌┐└┘├┤┬┴┼▼► 等,
典型为拓扑图 / 部署图 / 信号链路图 / 流程图),这是 ASCII 字符画——必须主动提醒用户:
- ASCII 字符画直接转 docx 只能得到等宽文本块,观感差且不正式;
- 建议用
fireworks-tech-graphskill 将其重绘为正式 SVG/PNG(该 skill 会做几何校验与视觉审查); - 重绘后以
语法替换 ASCII 代码块(转换器已支持图片渲染:居中、15cm 等比缩放、题注); - PNG 与 md 放同目录(相对路径引用),然后重新执行转换。
转换器运行时也会自动检测并打印同类提醒([提示] 检测到疑似 ASCII 字符画…),见 _looks_like_ascii_art()。
用户明确表示"就保留 ASCII"时尊重其选择,转换照常进行。
Pipeline (do this in order)
- Generate with
scripts/convert_doc.py:python scripts/convert_doc.py SOURCE.md OUTPUT.docx \ [--title "文档主标题"] [--no-toc] [--no-header-footer]pythonmust be a venv withpython-docxinstalled. If missing:python -m venv venv && venv\Scripts\pip install python-docx(Windows;POSIX 为venv/bin/pip).- The first
#heading becomes the Title (overridable via--title). - Cover page: the title is split on
——into a main title (28pt) + subtitle (16pt); the meta block between the title and the first##is parsed — markdown tables become real centered tables (e.g. 项目属性), other lines (作者/版本/日期) become centered paragraphs. The cover is followed by a standalone 摘要 page, then the TOC page. Seereferences/format_spec.md§2.5. - Heading levels are mapped by 篇/章/节 semantics, not raw
#count (seereferences/format_spec.md§3). If the document uses a different structure, tune the single function_heading_style()inconvert_doc.py. - Citations
[n]/[n,m]/[n-m]become superscripts in body/appendices; inside the 参考文献 section and inside code spans they stay literal. Details inreferences/format_spec.md§4.
- Verify citations with
scripts/verify_superscript.py:
Expect: body citations all superscript, 参考文献-section entries all plain, 参考文献 table all plain. Exit code 0 = pass.python scripts/verify_superscript.py OUTPUT.docx - Audit format with
scripts/audit_docx.py:
Checks heading levels, double-numbering risk (numPr), heading/body fonts & sizes, TOC field, header/footer/page-number fields, page size, table count, and (withpython scripts/audit_docx.py OUTPUT.docx \ [--source SOURCE.md] [--checks "关键词1,关键词2"]--source) heading-count diff + retained key terms. - Consistency check with
scripts/verify_fidelity.py(源 md ↔ docx 逐块保真):
Block-level content audit that locates the exact sentence/cell if anything went missing. Forward coverage (source -> docx, the pass/fail criterion): every source text unit (heading / paragraph / table cell / quote / list item) must appear as a substring in the docx. Backward spot-check (docx -> source, informational): lists docx body paragraphs not found in the source (possible additions), whitelisting converter-added cover/TOC/header/footer templates (date, TOC placeholder). Exit 0 = no source content missing. Run this whenever the user asks for a 一致性审查 / 保真核验, or after every reconversion to prove 100% fidelity.python scripts/verify_fidelity.py SOURCE.md OUTPUT.docx [--show N]
Critical rules (do NOT violate)
- NEVER modify the source Markdown. The source is absolute-authority; if the docx looks wrong, it's a converter issue, not a source issue. Fix the converter, never the source.
- Never "select all → change font" in Word. That only rewrites
w:ascii/w:hAnsi, notw:eastAsia, silently breaking Chinese fonts and flattening all sizes. Change fonts/sizes in the Markdown source and re-run the converter instead. - No Word auto multi-level numbering (keep
numPr=0). Manual "第N章 / 2.1" text is the sole numbering source; adding auto-numbering creates double numbering. - Ordered lists are literal "N. " text, NOT Word auto-numbering. Using Word's built-in
List Numberstyle causes cross-list continuation (a later list resumes numbering from an earlier one). Instead, the converter preserves the source's literalN.prefix as plain text in aNormal-style paragraph with a hanging indent of 0.63 cm. This guarantees each list matches the source exactly — no continuation, no fabrication. - Bullet lists use
List Bulletwith•(U+2022) + Times New Roman font._fix_bullet_style()changes both the bullet character AND the font: Word's defaultList Bulletuses the Symbol font with a private-use character; if only the character is changed to•but the font stays Symbol, Word renders an empty square (□) because Symbol has no glyph for U+2022. - Strict fidelity. Do not invent, add, or drop any text, data, or term. Citations and figures must match the source exactly.
- TOC is a field. Tell the user to right-click "更新域" in Word to populate it; the placeholder text is intentional, not an error.
- Do not hand-edit the generated
.docxto "fix" issues — manual Word edits corrupt eastAsia fonts and break fidelity with the source. Re-run the conversion instead.
Output notes
- Deliver the
.docx. Optionally mirror to a versioned copy (_v3.docx) if the user keeps numbered drafts. - After generation, report heading counts, table count, and the verify/audit summary to the user.
- If the source Markdown changes later, re-run step 1–3; no manual docx editing needed.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

