mp-format

A converter that turns finished Markdown or Word manuscripts into HTML for WeChat public-account posts, plus Markdown for Xiami-style editing.

In plain words
What is it for?
Use it to format quotations, notes, images, captions, author cards, and source cards, with optional Traditional-to-Simplified Chinese conversion.
Why use it?
WeChat posts need inline styling and reader-friendly formatting because they do not use external stylesheets in the same way as a normal website.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/midnightdarling/collate/mp-format
Any agent
npx skills add MidnightDarling/collate --skill mp-format
Clone the repo
git clone --depth 1 https://github.com/MidnightDarling/collate

Made for: Claude Code, Codex.

Per session 215 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,315 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00215 $0.02315
Opus 5 $0.00108 $0.01157
Sonnet 5 $0.00043 $0.00463
Haiku 4.5 $0.00021 $0.00231

Measured 2d ago against content hash 7b59aba2d0dc, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

mp-format scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/md_to_wechat.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/mp-format/SKILL.md · 154 lines

How it starts

The opening of the file, as written. The whole thing — 154 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Markdown → 公众号推文

Task

用户的 Word 稿是给学界看的,公众号版是给公众看的——要求不一样:

维度 Word 版 公众号版
字体 宋体 无衬线(苹方 / 微信默认)
繁简 保留繁(学术版本) --simplify 把正文简化,blockquote 保留原貌
脚注 页底编号 正文内 <sup>[1]</sup>,文末集中列出
引文 无特殊样式 灰底 + 左竖条的引用框
图片 正文流式 满宽 + alt 做题注

输出(落在工作区 output/ 目录,与 to-docx 的 Word 稿并列):

<workspace>/output/<title>_<author>_<year>_wechat.html  ← 带内联 CSS,粘贴到公众号后台 / 直接上传
<workspace>/output/<title>_<author>_<year>_wechat.md    ← 秀米兼容 Markdown(用户想进一步精修时用)

路径约定:输出由脚本自动推导:优先 _internal/_import_provenance.json,缺失时回退到 meta.json 与 Markdown 标题,不用显式指定 --output。权威规范见插件的 references/workspace-layout.md

Process

Step 1:确认输入

INPUT="<markdown-path>"
test -f "$INPUT" || { echo "文件不存在"; exit 1; }

Step 2:繁简处理

历史论文常见繁体字、异体字。公众号读者大部分读简体更顺。

默认不简化。传 --simplify 时,脚本用 OpenCC(t2s:繁 → 简)处理正文,但跳过以 > 开头的 blockquote(引文保持原貌,学术引文忠实要求)。

注意:脚本只保护 > 引用块,不识别 「」""『』 内的短引文。如果你的正文里有大量夹杂短引(「如此」「若是」),整段会被一并简化。若必须忠实保留这类短引,用默认(不传 --simplify)或手动在 Markdown 里把关键片段抽进 blockquote。

什么时候加 --simplify

场景 处理
纯学术古籍研究(读者是学界) 不加 --simplify,原样输出
现代简体论文(本来就简体) 不加 --simplify,脚本不动字
民国排印 / 偶有繁体(读者是公众) --simplify,blockquote 自动保留

Step 3:调排版脚本

# --output / --also-markdown 都省略;脚本按工作区约定把两份文件放到 <ws>/output/
python3 "${CLAUDE_PLUGIN_ROOT}/skills/mp-format/scripts/md_to_wechat.py" \
    --input "$INPUT" \
    --also-markdown \
    $( [ "$SIMPLIFY" = "1" ] && echo "--simplify" ) \
    --byline "$BYLINE" \
    --source "$SOURCE"

脚本会打印两行 [md_to_wechat] wrote <path>,第一行是 HTML,第二行是 Markdown。需要自定义路径(CI / 回归测试)仍可传 --output path--also-markdown path

脚本产出 HTML 特性(这些是脚本真正实现的,别过度承诺):

  1. 全内联 CSS(公众号后台剥离外联 style,所以每条规则都 inline 在 style 属性里)
  2. 标题层级
    • # → 22 px 加粗 深灰(同时 byline + source 会作为 meta 行放在 H1 下面)
    • ## → 18 px 加粗 左侧橙色竖条
    • ### → 16 px 加粗
  3. 引用块 >:灰底 + 左竖条 + 字号小一点
  4. 脚注[^1] 转成 <sup>[1]</sup>[^1]: ... 形式的定义抽到文末「注释」区
  5. 段首缩进:2 em(公众号移动端阅读友好)
  6. 图片:满宽 + alt 文本当题注显示在图片下方
  7. 作者 / 来源栏:byline 和 source 以 "·" 连接,居中显示在 H1 下方
  8. --also-markdown:再额外输出一份 Markdown(顶部拼上 byline / source 斜体行),供秀米 / 壹伴导入

Read the full file on GitHub · 154 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 154 lines · 215 tokens per session scan A 7b59aba2d0dc

Subscribe to this mod's changes

mp-format is a skill published in the GitHub repository MidnightDarling/collate (6 stars, last pushed 3mo ago), licensed Apache-2.0. It adds 215 tokens to every session and 2,315 once invoked, about $0.0011 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.