docx-creator
Produce Word (.docx) and export existing Word/WPS manuscripts to PDF (Word 转 PDF / 试读版 / 排版修复), preserving revisions, tables and images. Especially for Chinese documents, drive minimax-skills:minimax-docx OpenXML correctly. Use whenever the deliverable is a .docx file: 生成 Word 文档 / 做一份 docx / 写合同 docx / 起草协议 / 正式文书 / 公文 / offer / 劳动合同 / 把 markdown 转成 Word / Word 排版 / 中文排版 / 签字栏 / 盖章版 / 甲方乙方, or any plain "give me a Word file" request. This skill adds the layer minimax-docx does not ship: a verified markdown-to-docx OpenXML generator, alignment rules for info and signature blocks, list numbering, CJK font dual-slot setup, and a mandatory LibreOffice-to-PDF-to-PNG visual verification chain (qlmanage thumbnails are banned — they hide exactly the bugs that matter). Engine belongs to minimax-docx; correct usage and field-tested workarounds belong here. For Markdown → PDF use daymade-docs:pdf-creator.
1How It Works & Mechanism
Layered design: The engine is entirely outsourced to minimax-skills:minimax-docx (a third-party marketplace plugin); this skill contains zero engine code, providing only "battle-tested usage knowledge + a self-developed generator".
Thin incremental layer over **`minimax-skills:minimax-docx`**. Not a document engine.
Chinese formal document generation is implemented via an included C# generator: Program.cs (~260 lines of OpenXML + Markdig) parses Markdown into an AST and assembles docx according to ECMA-376.
var mdText = File.ReadAllText(args[0]); var pipeline = new MarkdownPipelineBuilder().UsePipeTables().Build(); var docAst = Markdown.Parse(mdText, pipeline);
Machine-verifiable alignment rules: Paragraphs containing LineBreakInline (Party A/Party B info blocks, signature blocks) are forced to left-align, while standard body text is justified—determined via the inline tree rather than human visual inspection.
The rule is machine-checkable, so do not eyeball it: if the markdown paragraph's inline tree contains a `LineBreakInline`, left-align that paragraph; otherwise justify it.
List numbering correctness relies on OpenXML semantics: Each independent list receives its own NumId + LevelOverride(StartOverrideNumberingValue=1); reusing the same NumId causes clause 3's list to continue numbering from 4.
Each independent markdown list must get its **own** `NumId` plus a `LevelOverride` carrying `StartOverrideNumberingValue = 1`. Reuse one `NumId` across clauses and clause 3's list silently continues from 4.
CJK fonts must use dual slots (Ascii/HighAnsi/EastAsia in RunFonts), Chinese bold text switches to SimHei/HeiTi (SimSun lacks true bold; synthetic bold blurs characters); font sizes use OpenXML half-points.
A run must set `RunFonts { Ascii, HighAnsi, EastAsia }`. Setting only the Latin slots leaves Chinese characters to Word's fallback
Mandatory visual verification chain: Generation → XSD validation (minimax CLI) → LibreOffice headless conversion to PDF → pdftoppm to PNG → page-by-page Read; qlmanage thumbnails are explicitly prohibited (ISSUE-008).
**Banned: `qlmanage` thumbnails as visual proof.** macOS Quick Look renders with a different engine than Word and will happily show a clean-looking page for a document whose info blocks are stretched apart.
Document routing table directs Word/WPS manuscripts → PDF and Markdown → PDF to word-to-pdf.md and pdf-creator respectively, explicitly prohibiting round-tripping authoritative Word manuscripts through Markdown.
| Existing Word/WPS → repaired layout / selected excerpt → PDF | Keep the Word source; follow `references/word-to-pdf.md` and `references/verification_protocol.md` |
2Core Capabilities
3External Dependencies
| Kind | Dependency / Endpoint |
|---|---|
| cli | dotnet SDK / dotnet run |
| package | DocumentFormat.OpenXml 3.2.0 + Markdig 1.3.2(NuGet) |
| cli | minimax-docx 引擎 CLI(第三方市场插件 minimax-skills,XSD 校验) |
| cli | LibreOffice soffice --headless(验证转 PDF) |
| cli | poppler pdftoppm(PDF→PNG) |
| cli | Microsoft Word.app(可选,macOS 兼容模式复核) |
4Recommended Governance & Evidence
- scripts/: Executes local script or command: dotnet run (locally compiles and executes bundled Program.cs)
- 网络端点: Declares external network access: Initial dotnet run restores DocumentFormat.OpenXml/Markdig via NuGet (SKILL/README explicitly state ~20s)
- 本地工作目录: File read/write and artifact output: Generates/overwrites user-specified out.docx (SKILL warns to check ~$ lock files first); copies generator to adjacent _docxgen/; writes verification artifacts to /tmp/docx
5Second-Pass Verification
- [ok] 零引擎代码、能力在 minimax-docx — SKILL.md 自述 'This skill contains zero engine code';本仓 grep minimax-docx 仅命中路径引用,引擎目录不在仓库内——外置关系属实。
- [unlocatable] minimax-docx validate CLI 行为 — CLI 位于宿主 ~/.claude/plugins/marketplaces/minimax-skills/…,不在本 pin 源码内,其 XSD 校验具体行为无法在此核验;SKILL 自身亦承认依赖其安装。
- [ok] 自研生成器 Program.cs — File.ReadAllText+Markdown.Parse+OpenXML 组装流程与 csproj 依赖(OpenXml 3.2.0/Markdig 1.3.2/net10.0)属实;对齐/NumId/字体双槽注释在源码中可定位。
- [ok] qlmanage 禁令与 ISSUE-008 叙事 — SKILL.md Banned 段与 known_issues.md ISSUE-008 记录一致;verification_protocol.md 亦重申。
- [ok] ISSUE-012 真 Word 兼容模式案例 — known_issues.md 含根因(元素顺序/缺 tblGrid 等)与 'LibreOffice 全绿、真 Word 兼容模式' 的复现记录;verification_protocol Step 3a 强制 Word 复核。
- [ok] NuGet 首次还原需网络 — SKILL.md quick start 注明 '(first run restores DocumentFormat.OpenXml + Markdig, ~20s)';scripts/README 依赖表 'NuGet reachable' 行一致。
- [ok] 无凭证/无外发代码 — Program.cs/README/引用文件 token 扫描:无 env 密钥、无 requests/urllib、无 curl;网络仅 NuGet 还原。
- [ok] 元数据 — GitHub API:MIT / 1385 stars / pushed 2026-09-09T12:33:29Z;本地 HEAD==pin d5c4678。
6Verdict & Scenarios
31fc8fead4571a90…