| name | cmm-typesetting |
| description | Use this CMM skill to typeset finished article drafts into WeChat-compatible publish HTML (long-form line) OR into XHS card sets (card line). Long-form uses blocks.yaml + render_wechat.py plus CJK punctuation preflight and optional theme-gallery review. Card line uses card_text_map.yaml + render_card.py (3 templates: xhs-quick-knowledge / xhs-checklist / xhs-quote-poster, 9 skins total). Use when the user wants 公众号排版, 图文卡片, 小红书卡片, 卡片模板, or when the pipeline reaches typesetting. Does not write content, generate images, or publish. |
CMM Typesetting
cmm-typesetting is the typesetting station of the long-form (长图文) production
line. It consumes a finished draft (content_package body + illustration_map
assets) plus style_selection.layout, and produces WeChat-ready HTML.
Boundary
Use this skill for:
- Mapping a finished article into a semantic block sequence (
blocks.yaml).
- Rendering publish.html / preview.html with a theme + components.
- Running layout checks (paragraph length, visual breaks, component density,
WeChat-risk styles).
Do not use this skill to:
- Write or edit article content (cmm-content-writing).
- Plan or generate images (cmm-visual-production / cmm-image-creator).
- Publish or create platform drafts (cmm-publishing).
Workflow
- Inputs: draft markdown (with
[插图] placeholders resolved against
illustration_map), theme id from style_selection.layout, user profile
(~/.cmm/profile/) for footer_cta ritual text.
- CJK punctuation preflight before mapping. Run the checker in non-writing mode
first:
python3 {baseDir}/scripts/cjk_punctuation_check.py draft.md --check
If it reports issues, preview the fix:
python3 {baseDir}/scripts/cjk_punctuation_check.py draft.md
Only run --write after the user approves editing the source file. If source
edits are not approved, record the punctuation issue in the handoff notes and
continue from an explicitly copied/temporary draft.
3. Semantic mapping (the agent does this): read
references/wechat-components.md (content-feature → component table, C1
final rules, density discipline) and references/blocks-contract.md, then
write blocks.yaml. Do not hand-write HTML.
4. Deterministic render:
python3 {baseDir}/scripts/render_wechat.py --blocks blocks.yaml --out-dir ./typeset [--theme wechat-claude]
- Read
report.json. Fix fail items by editing blocks (split paragraphs,
add breaks); judge warn items (gradient/negative-margin risks need the
one-time WeChat paste test).
- Optional theme-gallery review when the user is choosing style, complains the
look is wrong, or the content has no pinned layout:
python3 {baseDir}/scripts/render_theme_gallery.py --blocks blocks.yaml --out-dir ./typeset-gallery --open
This renders the same article through the curated WeChat theme set and writes
gallery.html for visual selection. Once a theme is selected, re-render the
final package with render_wechat.py and record the chosen theme.
7. Preview gate: open the rendered HTML and cover image for user review before
handing off to cmm-publishing:
open ./typeset/publish.html
open <cover_image_path>
Tell the user the output paths. Wait for explicit confirmation before
proceeding to step 8. For WeChat long-form runs, this confirmation must cover
title, final body, cover text, cover image, body-image placement/order, and
whether to create the platform draft-box item. A user's earlier instruction
to "publish to draft box" sets the target, but does not approve the unseen
preview.
8. Hand publish.html + assets to cmm-publishing.
References
references/blocks-contract.md — blocks.yaml schema and commands.
references/wechat-components.md — 15 components, selection rules, C1 final,
WeChat compatibility preflight, and xiaohu-style practical container mapping.
references/themes/wechat/ — 公众号长文排版规格卡 (fits/signature/text rules);
references/themes/xhs/ — 小红书卡片布局规格卡。模板唯一事实源见
cmm-content-factory/references/registry/(role wechat / xhs-card)。
references/skins.yaml — per-theme color tokens + behavior flags; the
renderer builds all element styling from these tokens (CMM-native, self-contained).
minimal themes auto-reduce decoration.
Theme Quick Map
实用系: tech-blue(教程) business-navy(商务) tech-simple(开发者) claude(AI暖,宋体衬线) warm(暖系:奶油底+黏土橙+纤细)
阅读系: deepread(叙事长文默认) medium(博客) clean-column(随笔)
杂志系: latepost(深度报道, C1-D) hische(西式杂志, C1-D)
特殊系: conference/发布会(产品感灰正文, minimal) elegant(中式书卷) kenya(极致留白, ≤800字)
Selection comes from style_selection.layout
(cmm-content-factory/references/styles/selection-rules.md); a same-turn user
instruction overrides.
Card Line (图文卡片)
Three templates for XHS 3:4 cards (750×1000px):
| Template | Fits | Skins |
|---|
xhs-quick-knowledge | tool overview, AI news, insight summary | cool / warm / neutral |
xhs-checklist | step tutorial, how-to, N件事 | green / blue / purple |
xhs-quote-poster | key quotes, opinion closer, series ender | ink-white / dark-warm / paper |
Agent writes card_text_map.yaml per references/card-text-map-contract.md.
python3 {baseDir}/scripts/render_card.py --input card_text_map.yaml [--skin warm] --out-dir ./out
Output: preview_cards.html (50% scaled, all cards), report_cards.json.
Samples: ~/.cmm/samples/cards/demo-*.yaml.
XHS 图片生成注意事项
topic_context 字段:如果话题名称存在歧义(例如"循环工程"可能被图像模型误读为"编程循环"),在 card_text_map.yaml 的 meta 节下添加 topic_context 字段,用一句话澄清正确含义。该字段会注入每张卡片的图像生成提示词。
anchor 图片尺寸限制:用前一张卡片的输出作为下一张的参考图(anchor)时,大图片经 base64 编码后作为 jq 参数传递会触发 shell Argument list too long 报错。遇到此情况,为受影响的卡片单独建一个不含 anchor 引用的 yaml 文件,跳过 anchor 单独生成即可。
Stop Conditions
- Never publish or push to platforms; output stays local.
- If the draft has unresolved
[插图] placeholders, render them as pending
boxes and list them in the handoff notes instead of inventing images.