dbs-wechat-html
Converts Markdown into WeChat Official Account-compatible HTML ready for pasting into the admin backend, offering 15 built-in styles. Used when users request generating Official Account HTML, creating a WeChat version, or formatting WeChat articles.
1How It Works & Mechanism
The entire skill is designed around 'model as transformer': writing no scripts, relying on an extremely detailed conversion rule set plus an external style library to turn Markdown into paste-ready HTML.
执行前必须读取 `templates/styles.md`,按里面的 style id、别名、适用场景和 CSS 生成。样式库中的 CSS 是设计源,生成时必须按本文件的「微信粘贴兼容性」规则展开到具体 HTML 元素。
The design premise is that copying from a browser loses the <head>/outer containers and the WeChat backend performs secondary sanitization, so all visible styles must be inlined onto every single element.
正式交付 HTML 禁止使用:
Conversion consists of two stages: first mapping Markdown to HTML structure, then performing 'inline style expansion' and removing <style>/class/id/pseudo-elements.
2. 把选择器中的属性写到每个匹配的可见元素上。
Eliminates duplicate titles in WeChat Official Accounts by default: the first level-1 heading goes only into <head><title> and is not rendered as an <h1> in the body.
- 不把这个一级标题渲染为 `<body>` 中的 `<h1>`;
Three entry points for style selection: a natural language mapping table (15 mappings), CLI arguments (--style/--recommend/--preview/--all), or a four-choice follow-up prompt if unspecified.
| `--preview` | 生成 6 个推荐风格 + 总览页 |
Deliberate trade-offs in Markdown conversion: tables convert to lists rather than <table> (due to poor WeChat compatibility), images become placeholders without inlining, hard breaks do not convert to <br>, and trailing Chinese periods in paragraphs are stripped.
8. 表格不直接生成 `<table>`,微信公众号兼容性差。优先转换为列表。
Provides 9 pre-delivery static checks alongside executable validation commands (rg should yield no matches).
rg -n '<style|class=|id=|:before|:after|<script|https?://|@import' "输出文件.html"
Standardized output locations and naming: written to 公众号HTML输出/ alongside the source file, with filenames containing the style id and name; multi-style outputs include an overview page and a style directory.
文件名:`原文件名_style-id_风格名_微信公众号版.html`
Clear branding and network boundaries: no network fetching of fonts/CSS/images/scripts, no replication of original source media branding assets, adopting only typographic paradigms.
- 不要把来源媒体的品牌资产、logo、专有视觉原样复制进 HTML。这里只借鉴排版范式。
2Core Capabilities
3External Dependencies
| Kind | Dependency / Endpoint |
|---|---|
| cli | xmllint(可选的 HTML 结构校验;缺失时用等价工具) |
| cli | rg(可选:扫描 style/class/伪元素/脚本/外链等违规项) |
4Recommended Governance & Evidence
- 本地工作目录: File I/O and artifact generation: generates HTML files in the 公众号HTML输出/ directory alongside the source Markdown (filenames include style id and style name)
5Second-Pass Verification
- [ok] 目录仅 3 个文件、无脚本可执行 — find skills/dbs-wechat-html -type f 返回 SKILL.md、agents/openai.yaml、templates/styles.md。
- [ok] 无网络外发(不加载外部字体/CSS/图片/脚本) — 全文 URL/字体/CDN 相关命中均为禁止条款与本地校验示例;无 fetch/curl/http 请求指令。
- [ok] 15 个风格 id 与样式库条目一一对应 — SKILL.md 风格表 15 项与 styles.md 的「01 minimal … 15 event」15 个小节完全对齐。
- [ok] 粘贴兼容性规则与实际检查项一致 — "禁止 <style>/class/id/伪元素/JS/外链"与静态检查 1–3 条、rg 扫描表达式互相覆盖。
- [ok] "执行前必须读取 templates/styles.md"确有对应资产 — 样式库文件存在(197 行),开头自述为样式权威来源。
- [ok] 无凭证读取 / 无远程调用 — 全文无 env/API_KEY/token/keychain 类指令,也无任何外部服务调用。
- [ok] 写盘范围是否被夸大或漏记 — SKILL.md 明确输出目录、文件名规则与总览页/风格目录三处产物,已如实记入 file_writes(含用户直接贴 Markdown 时改用当前工作目录)。
- [ok] "不复制品牌资产"的边界声明 — 注意事项原文存在;属设计纪律,已在 traits/risks 中如实标注为"范式相似仍可能联想"。
6Verdict & Scenarios
ab53f46d3e3f4706…