ZJU-REAL/Easel / skills/builtin/gzh-design
gzh-design
Verified微信公众号文章排版引擎:把 Markdown / Word(.docx) / PDF / 纯文本转成可直接粘贴进公众号编辑器的 HTML,自动章节编号、关键词标记、引言卡、目录、代码块、图片/GIF、作者签名;主题从 references/theme-index.md 组件库按题材推荐,支持"一键自动排版"与按描述/参考图生成自定义主题。触发:用户提到"公众号排版/微信排版/gzh"、想把文章(md/docx/pdf/纯文本)转成公众号 HTML、说"自动排版/一键排版"公众号内容。不用于普通网页/落地页/PPT。
references/format-normalize.md
View on GitHub# 格式归一化 —— 万物先转 Markdown,再进排版流程
排版流程只认 Markdown。任何非 Markdown 输入,先按本文件转成 Markdown 草稿,**经结构确认后**再进 SKILL.md 第 1 步选主题。转换只整理结构,**不得增删改写原文实质内容**。
## 输入类型判定
| 输入 | 判定依据 | 处理 |
|---|---|---|
| Markdown | `.md` 后缀,或文本含 `#`/`##`/`![]()` 等标记 | 直接进流程(剪存元信息按 gotcha 剔除) |
| Word | `.docx` 后缀 | 跑 `scripts/extract_docx.py`(见下) |
| PDF | `.pdf` 后缀 | 用 Read 工具分页读取 + 清噪规则(见下) |
| 纯文本 | `.txt` 或粘贴的无标记大段文字 | 语义推断结构(见下) |
| 网页/富文本 | HTML 标签或明显剪贴板样式残留 | 剥样式、按语义映射成 Markdown |
| `.doc`(老格式) | 后缀 | 无法直接解析——请用户在 Word/WPS 里另存为 .docx 再来 |
## Word(.docx)
```bash
<SKILL_ROOT>/scripts/extract_docx.py 文章.docx -o 文章.md
```
脚本零依赖:标题样式(Heading/标题 1-6)→ `#`–`######`,粗体→`**`,下划线→`<u>`,列表→`- `,内嵌图片解包到输出目录 `images/` 并以相对路径引用。表格会留 `[表格:…]` 占位——转成列表、重新截图,或问用户怎么处理。跑完把生成的 md 读进来走结构确认。
## PDF
用 Read 工具直接分页读取(原生支持 PDF),读完按下列规则清噪再组装 Markdown:
1. **删页眉页脚**:每页重复出现的同一行(书名/章节名/URL)、纯页码行(`12`、`- 12 -`、`Page 12`)。
2. **合并硬断行**:行尾无句末标点(。!?;:)且下一行以小写字母/中文续接 → 拼成一段;行尾是标点 → 保留分段。
3. **识别标题**:字号信息拿不到,用纯文本启发式(见下节)。
4. **图表**:PDF 里的图无法提取,位置留 `【配图:原 PDF 第 N 页图】` 占位(会渲染成居中待补板块)。
5. 双栏 PDF 常见串行错乱——发现语句前后不接,提醒用户该 PDF 可能需要人工整理。
## 纯文本(.txt / 无标记粘贴)—— 语义推断结构
**标题识别启发式**(满足越多越可信):
- 行长 ≤ 20 字,且不以句末标点(。!?)结尾
- 前后都是空行(或位于全文/段落群开头)
- 带序号前缀:`一、` `二、` `1.` `01` `第X章/节/部分` `Part N` `PART N`
- 与后文构成"短行 + 多个长段"的节奏
**分级**:全文最高频的标题模式定为 `##`;其下一级(若有)定为 `###`;文首孤立短行定为 `#` 文章标题。
**全文识别不出任何标题时**:按语义把内容切成 3–6 个主题块,为每块自拟一个 ≤12 字的章节标题(标题要说人话、贴内容,不要"第一部分"这种空壳),并在结构确认时明确告诉用户"这些标题是我起的"。
其余映射:空行分段;`"引号金句"`/破折号署名 → 开头引言候选;`1. 2. 3.` 或 `·`/`-` 起头的行 → 列表。
## 网页 / 富文本
`<h1-h6>`→`#`级别,`<strong>/<b>`→`**`,`<img src>`→``(外链 URL 原样保留),`<li>`→`- `,`<blockquote>`→`> `;样式属性、span 嵌套、` ` 等垃圾全部剥掉。剪存工具的元信息块(原文链接/剪存时间/工具署名)不属于正文,剔除。
## 结构确认(默认必做,全自动模式除外)
归一化完成后、选主题之前,把推断结果给用户扫一眼:
> 识别出 N 个章节:01 xxx / 02 xxx / …(其中第 3、5 个标题是我起的)。图片 M 张。结构对吗?
结构错了排出来全错——这一步花 10 秒,拦住的是整篇返工。用户确认或修正后再进第 1 步。
## 全自动模式(用户给纯文本 + 要"直接排"时)
用户说「直接排」「自动排」「一键排版」「不用问我」,或明显只想要结果时:
1. 跳过结构确认与选主题提问,**全链自动**:推断结构 → 按题材从 theme-index 自选最贴的主题 → 排版 → 校验。
2. 交付时**补一段决策说明**(不是征求同意,是让用户可审计):识别出的章节结构、自拟了哪些标题、选了什么主题及理由。
3. 用户对任何决策不满意,按点改(换主题重排 / 改章节切分),不用重来。
自动选主题就按 theme-index「选择建议」:无明显题材倾向 → 红白色系。
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |