gongwen-format
Skill9 starsChanged 15 days agoMITView on GitHub
公文排版技能,将 .docx 文档按照中国公文格式规范进行排版。当用户提到'公文排版''公文格式''格式化公文''公文版式''按公文格式排版'等关键词时自动触发。将文档标题设为方正公文小标宋,正文设为仿宋_GB2312,统一字号、缩进、页边距等格式要素。
- Installs packages
2 other projects use a version of this.
Adopted by
Most recently taken up by
- duyunzhoudyz/dyz-gongwen-skillstheir own version, first seen Nov 8, 2026
- duyunzhoudyz/gongwen-skillstheir own version, first seen Oct 25, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- duyunzhoudyz/dyz-gongwen-skills★ 995same name
- duyunzhoudyz/gongwen-skills★ 995same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository14 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- skills/claude-to-im/CLAUDE.mdCLAUDE.md
- tianshu-hubSkill
- case-analyzerSkill
- case-intake-kitSkill
- claim-chartSkill
- claude-to-imSkill
- contract-reviewSkill
- court-smsSkill
- evidence-organizerSkill
- funasr-transcribeSkill
- judgment-analyzerSkill
- mineru-ocrSkill
The file
Files
公文排版
将 .docx 文档按照中国公文格式规范进行自动排版。
格式规范概要
| 元素 | 字体 | 字号 | 其他 |
| 标题 | 方正公文小标宋 | 二号 (sz=44, szCs=52) | 加粗, 居中 |
| 标题后空行 | 仿宋_GB2312 | 四号 (sz=28) | 空段落 |
| 称呼/抬头 | 仿宋_GB2312 + Times New Roman | 四号 (sz=28) | 加粗, 无缩进 |
| 正文 | 仿宋_GB2312 + Times New Roman | 四号 (sz=28) | 首行缩进2字符 |
| 一级标题 (一、二、) | 仿宋_GB2312 + Times New Roman | 四号 (sz=28) | 加粗, 首行缩进2字符 |
| 二级标题 ((一)(二)) | 仿宋_GB2312 + Times New Roman | 四号 (sz=28) | 加粗, 首行缩进2字符 |
| 签名/落款 | 仿宋_GB2312 + Times New Roman | 四号 (sz=28) | 右对齐 |
| 页面设置 | 值 |
| 纸张 | A4 (11906×16838 DXA) |
| 上下边距 | 1440 DXA (2.54 cm / 1 inch) |
| 左右边距 | 1800 DXA (3.18 cm / 1.25 inch) |
| 页眉距边界 | 851 DXA |
| 页脚距边界 | 992 DXA |
| 行距 | 固定值28磅 (w:line="560" w:lineRule="exact") |
| 页码 | 默认开启:页脚居中阿拉伯数字,四号;原文档已有页脚时跳过;--skip-page-number 关闭 |
| 段间距 | 默认(去除显式设置) |
工作流程
前置条件
- Python 3,第三方依赖
lxml(pip install lxml) - 排版脚本:本 skill 目录下的
scripts/format_gongwen.py - 解包、打包 docx:docx 本质是 zip 包。有 docx skill 就用它的
unpack.py、pack.py;没有就用本仓库skills/contract-review/scripts/ooxml/下的unpack.py、pack.py(pack.py另需pip install defusedxml)。下文命令以后者为例,<仓库>指本仓库根目录
步骤
- 确认输入文件:用户提供待排版的 .docx 文件路径
- 解包文档:
python "<仓库>/skills/contract-review/scripts/ooxml/unpack.py" "输入文件.docx" "unpacked_gw"- 执行排版(一步完成所有格式替换):
python "<仓库>/skills/gongwen-format/scripts/format_gongwen.py" "unpacked_gw"脚本自动完成:页面设置、标点规范化、标题处理、称呼行处理、正文字体/字号/缩进统一、行距统一、装饰元素清理、签名区域处理、styles.xml 修改。
可选参数:
--skip-styles:跳过 styles.xml 处理--skip-punctuation:跳过标点规范化--skip-page-number:不加页码
标点规范化默认开启,规则:
- 半角标点转全角(仅含中文的段落):
( ) : ; ? !→():;?! - 中文字符后的
,.→,。(小数3.14、英文缩写U.S.不误伤) - 双引号各变体(含 ASCII
")按出现次序自动配对为中文左右弯引号,可跨 run - 省略号
.../。。/…→…… - 连续两个以上的半角短横线
--,以及单个或多个长横线(U+2014),统一规整为两个 U+2014 组成的中文破折号。不希望文中出现破折号的,加--skip-punctuation或排版前先在正文里改掉 - 保护:URL、邮箱、时间
12:30、标准号9001:2015中的标点保持不变 - 单引号不处理(避免英文撇号
don't被误伤);表格内段落同样规范化
- 打包输出:
python "<仓库>/skills/contract-review/scripts/ooxml/pack.py" "unpacked_gw" "输出文件(排版).docx"用 docx skill 的 pack.py 时,按它的参数写,例如 --original "输入文件.docx" --validate false。
- 收尾:告知用户输出文件路径。解包目录建议一开始就放在系统临时目录,交付目录里只留最终文件
注意事项
- 标题识别方法: 居中对齐 (
w:jc val="center") + 大字号 (sz>=36) - 称呼行识别: 标题后首个非空非缩进段落
- 签名区域识别: 右对齐 (
w:jc val="right") 的段落,保留其对齐方式 - 签名区域的
w:spacing w:before用于留白,应保留 - 一级标题识别: 文本匹配
^[一二三四五六七八九十]+、 - 二级标题识别: 文本匹配
^[((][一二三四五六七八九十]+[))] - 诉讼文书里带句号的长句式一级标题(超过 50 字或含"。!?")会被当成正文,不加粗;受文法院行可能被误加两字缩进。这类文书排完需手工补加粗、把受文法院改回顶格,或改用专门的诉讼文书生成工具
- 如果系统未安装"方正公文小标宋"字体,标题可能显示为默认字体
- 输出文件名为原文件名加"(排版)"后缀
- 详细格式规范参见
references/format-spec.md
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.

