Docx Export logo

Docx Export

Community
zhaohui-yang
docx-export

把中文公文 Markdown 成稿导出为符合机关版式的 .docx。Use when the user wants to export/convert a 公文 Markdown draft to Word/.docx, adjust 字体、字号、页边距、行距、页码、标题断行, embed local images as 附件/附图, or inspect the resolved 字体与版式方案. 不负责起草内容,只负责渲染版式。

Overview

Publisherzhaohui-yang
Repositoryofficial-document-drafting
Skill namedocx-export
Stars
148
Forks
19
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by zhaohui-yang on GitHub. Read the source before you install it.

Installation

Install the Docx Export AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/zhaohui-yang/official-document-drafting/tree/main/skills/docx-export
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/zhaohui-yang/official-document-drafting.git /tmp/official-document-drafting
mkdir -p .claude/skills
cp -r /tmp/official-document-drafting/skills/docx-export .claude/skills/docx-export
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Docx Export in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Docx Export on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Docx Export is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

公文 docx 导出

把已成稿的中文公文 Markdown 渲染成符合机关版式的 .docx。这是「版式渲染」能力,不起草内容——起草走根目录「公文写作」skill,本 skill 只在 Markdown 结构正确后做导出与版式调整。

与「公文写作」共用同一份 prompts/ 主源(字体方案、版式方案、文种绑定),不复制规则。

文件索引

src/scripts/generate_docx.py            # 导出器主入口(CLI)
src/scripts/install_fonts.sh            # 安装 assets/fonts/ 下字体到系统
src/scripts/download_fonts.sh           # 拉取开源替代字体
prompts/font-profiles/*.toml        # 字体方案(标题/正文/层级字体字号)
prompts/layout-profiles/*.toml      # 版式方案(固定行距、各段后距、首行缩进)
prompts/doc-types/<id>-<文种>/meta.toml  # 文种 → font_profile / layout_profile 绑定
assets/fonts/catalog.toml           # 字体族 → assets/fonts/ 具体文件映射
docs/references/font-usage.md            # 字体速查、导出已知坑、自检命令(面向读者)
docs/references/layout-rules.md          # 版式规范、已自动化/未自动化清单、页边距

调用方式

  • 先确认 Markdown 结构正确(标题、主送单位、正文、落款、附注、附件等用 ## 分块)。
  • 按文种自动套字体与版式:--doc-type <文种>(中文别名或英文 ID 均可),脚本据 meta.toml 解析 font_profile/layout_profile。
  • 或手动指定:--font-preset、--title-font、--body-font 等槽位。
  • 导出前可用 --show-font-plan / --show-layout-plan 预览实际落到的字体、字号、版式参数。
bash
python3 src/scripts/generate_docx.py 成稿.md -o 成稿.docx --doc-type 通知
python3 src/scripts/generate_docx.py --doc-type 报告 --show-font-plan      # 预览不导出

默认版式(主源)

  • 页边距:按 GB/T 9704-2012,上 37mm、下 35mm、左 28mm、右 26mm(版心 156mm×225mm;常量真身在 src/docgen/constants.py 的 MARGIN_*_TWIPS,经 src/scripts/generate_docx.py 再导出)。
  • 行距、各段后距、首行缩进:由文种绑定的 prompts/layout-profiles/*.toml 决定,不在文档里重复硬编码数值。
  • 标题/正文/层级字体字号:由 prompts/font-profiles/*.toml + assets/fonts/catalog.toml 决定。
  • 调整版式优先改对应 *.toml 主源;只在一次性需求时用 CLI 覆盖。

已知坑(症状 / 成因 / 对策)

  • 换机器字体变样:脚本只写字体名、不嵌入 .ttf;目标机器先 bash src/scripts/install_fonts.sh,锁定视觉时导出 PDF。
  • 图片没出现:仅支持本地 png/jpg/jpeg,用 ![图1 标题](./本地路径.png) 独立成块,优先放 附件/附图/附录。
  • 首页无页脚页码:预期行为(自第二页起显示);完全不要页码加 --hide-page-number。
  • 页脚灰底:是编辑器“域底纹”显示,非文档底纹。

更完整的字体速查与命令见 docs/references/font-usage.md,版式规范见 docs/references/layout-rules.md。

边界

  • 不在自动化范围:机关红头套版、印章压成文日期、完整套红线——仍需用本单位 Word 模板做最后核定。
  • 改字体/版式后若涉及 *.toml 主源,跑 python3 src/adapters/skill/build.py --check 确认产物同步。

Frequently asked questions

What does the Docx Export AI skill do?

把中文公文 Markdown 成稿导出为符合机关版式的 .docx。Use when the user wants to export/convert a 公文 Markdown draft to Word/.docx, adjust 字体、字号、页边距、行距、页码、标题断行, embed local images as 附件/附图, or inspect the resolved 字体与版式方案. 不负责起草内容,只负责渲染版式。

Why use Docx Export on TypingMind?

Because you install it once and use it with any model. Docx Export is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Docx Export in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/zhaohui-yang/official-document-drafting/tree/main/skills/docx-export. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Docx Export?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Docx Export?

As many as you like. As long as a model supports skills, you can use Docx Export with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Docx Export AI skill free?

It is published on GitHub by zhaohui-yang. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇