微信公众号排版HTML导入助手

SKILL内容创作
内容创作 未标注权限 许可证不明确
安装这个技能

适用场景:当用户提供一篇 HTML 文章(或 HTML 文件),并希望将其转换为微信公众号兼容格式、通过微信草稿接口发布为草稿时使用。 覆盖范围: 1. HTML 清洗——仅保留内联样式,剥离 script 与 head 等标签; 2. CSS 重置陷阱——例如标题标签丢失加粗样式等问题; 3. 占位图替换——将占位图片替换为可用素材; 4. 草稿创建——需要通过环境变量传入 AppID 和 AppSecret,并配合一张封面图才能完成草稿创建。

一句话选型结论

按资料字段整理

微信公众号排版HTML导入助手是内容创作类的 Agent Skill,安装方式未标注,权限级别未标注,许可证不明确,有可直接复制的安装命令。技能本质是给模型读的说明书,效果取决于模型与客户端;装完先用一个小任务验证,再放进正式流程。

分类内容创作 安装方式未标注 权限级别未标注权限 许可证许可证不明确
累计安装 未标注 本周 未标注
GitHub 星标 未标注 仓库 未标注
下载量 未标注 技能市场下载数
权限级别 未标注权限 安装前请确认风险范围
许可证 许可证不明确 未说明

安装

未标注
在支持 Skills 的客户端里执行,装完问一句「你有哪些技能」验证
skillhub install user_c0782da5/wechat-html-to-draft
  1. 1
    确认客户端支持

    确认你的客户端支持 Skills(Claude、Codex、Cursor 等),并升级到较新的版本。

  2. 2
    拿到技能文件

    执行上面的命令安装;也可以把仓库里的 SKILL.md 手动放进客户端的 skills 目录。

  3. 3
    刷新技能列表

    重新打开客户端,或刷新技能列表,让新放进来的技能被加载。

  4. 4
    验证是否生效

    问一句「你有哪些技能」,确认列表里出现它,再拿一个小任务试跑。

技能档案

内容创作
字段来自技能仓库与公开索引,中文说明由本站标注
作者 / 维护方user_c0782da5仓库 未标注 · 版本 未标注
宿主客户端未标注技能可被这些客户端加载
安装方式未标注安装包 community
权限级别未标注权限安装前请确认风险范围
许可证未说明许可证不明确,商用前请自行确认条款
仓库可用性available技能仓库当前是否可访问
最近核验未标注上游最后核验时间 · 数据更新 1791624971
正文体量9.3 KBSKILL.md 原文大小,越大说明说明书写得越细

典型使用场景

3 类
按分类整理的常见用法,具体以 SKILL.md 为准
写文章与脚本

按主题产出初稿与分镜脚本。

改稿与润色

把草稿改顺、统一语气。

多平台文案改写

同一内容按平台改成长短不同的版本。

选择建议

装之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有可直接复制的安装命令,不用自己翻文档找入口。

先想清楚的地方

  • 没有标注权限级别,实际能做什么要装好后确认。
  • 许可证不明确,商用或二次分发前先到仓库确认条款。
  • 没有做站内核验,内容以作者仓库为准。
  • 技能只是说明书,实际效果取决于模型与客户端,装完先用小任务试一遍。

更适合

  • 需要在内容创作场景里给模型补一套做法的人。
  • 愿意先读一遍 SKILL.md、确认它会让模型做什么的人。

不太适合

  • 对许可证要求很严、必须明确可商用的人。
  • 只想装完就自动变强、不打算看说明书的人。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
技能权限级别安装方式累计安装宿主客户端安装命令
微信公众号排版HTML导入助手当前 未标注权限 未标注 未标注 未标注 有
AI 视频生成 调用外部服务 GitHub 仓库 431.3 万 Codex、Claude、Cursor 有
视频帧 联网访问 ClawHub 市场 262.1 万 OpenClaw 有
Markdown 转换器 写入文件 ClawHub 市场 135.3 万 OpenClaw 有
哔哩哔哩全合一 接触敏感数据 ClawHub 市场 64.1 万 OpenClaw 有
Remotion video toolkit 命令行 浏览器控制 ClawHub 市场 63.9 万 OpenClaw 有

SKILL.md 全文

9.3 KB
模型实际读到的说明书原文,来自技能仓库

WeChat HTML to Draft

Overview

Convert an arbitrary HTML article into the restricted HTML dialect that WeChat Official Account (公众号) accepts, then publish it as a draft through the WeChat draft API (draft/add). The skill ships two scripts (a sanitizer and a draft publisher) plus a reference guide documenting WeChat's HTML filtering rules and the draft API.

When to use

  • The user hands over an .html file or raw HTML and asks to "发到公众号 / 转成公众号格式 / 上传草稿箱 / 生成草稿".
  • The user reports that pasted HTML "lost all styles" in the WeChat editor.
  • The user wants to fix WeChat-specific rendering issues (headings not bold, images missing, flex/grid layout collapsing).

Workflow

Step 1 — Sanitize the HTML

Run the sanitizer to strip everything WeChat rejects while keeping inline styles:

python scripts/convert_wechat_html.py <source.html> <output.html>

> Python 调用约定(重要):直接用 PATH 中的 python 命令(managed 版已加入 PATH),不要硬编码 python.exe 绝对路径——在 Git Bash 下绝对路径的 .exe 偶发“No such file or directory”。若 python 不可用,回退到 py 或 uv run python。

The script does these jobs: (1) removes <script>, <head>, <!DOCTYPE>, and <html>/<body> wrappers, preserving all inline style; (2) sanitizes for the 45166 invalid content error — strips <a> hyperlink tags (keep inner text; API rejects <a> even pointing to weixin), removes class/id/data-*/aria-* attributes, strips HTML comments, and deletes invisible Unicode (zero-width space \u200B, BOM \uFEFF, emoji variants \uFE0E/\uFE0F, bidi controls \u202A-\u202E) that slip in via copy-paste and trigger the undocumented 45166 check; (3) automatically injects font-weight:bold and explicit font-size into <h1>/<h2>/<h3> (h2→22px, h3→18px) to defeat WeChat's CSS reset that silently drops default heading bold; (4) converts every <div> into <section> — the single most important fix for "clicking 编辑 loses styles": WeChat's editor forces <div>→<p> on entering edit mode and drops most style, while <section> (the tag Xiuxi/135/official templates use) is kept intact; (5) unifies paragraph spacing — every <p> gets margin:1.2em 0 and every card <section> (with background/border) gets margin:20px 0, eliminating "段前段后距不一致". Pass --no-spacing to keep original margins; (6) by default minifies to a single line (no newlines/indentation) — a secondary guard against edit-mode whitespace normalization dropping inline styles. Pass --no-minify only for debugging. Write the result to a new file (e.g. <原名>_公众号版.html).

> Note on 45166 vs length: the 2万-character / 1MB content limit is a different error code (44016), NOT 45166. If draft/add returns 45166 invalid content, suspect <a> tags, class/id attributes, or invisible Unicode characters in the HTML — not length. This script auto-strips all of them.

Step 1.5 — Handle content images (only when the article has <img>)

WeChat silently filters any image whose src is NOT a WeChat-hosted URL (https://mmbiz.qpic.cn/...). That means base64-embedded, local-path, or external-link images all fail to display in the draft. They must first be uploaded via media/uploadimg to obtain a mmbiz URL, then the src replaced.

If the source HTML contains <img> with non-mmbiz src, run the image prep script before Step 1:

# 用隔离 venv 的 python(已装 Pillow 用于超图压缩;uploadimg 单图上限 ~1MB)
C:/Users/admin/.workbuddy/binaries/python/envs/default/Scripts/python.exe \
  scripts/upload_content_images.py <源.html> <图片已替换.html>

This decodes/reads each image, compresses to <950KB (resize to ≤1080px wide, fall back to JPEG), uploads via media/uploadimg, and rewrites src to the mmbiz URL. Then feed &lt;图片已替换.html&gt; into Step 1's convert_wechat_html.py. No manual &lt;img&gt; editing needed.

If the article has no images (only placeholder text like 【封面图片占位】), skip this step.

Step 2 — Verify CSS-reset pitfalls (mostly automated now)

WeChat applies a CSS reset that silently drops browser-default styles. convert_wechat_html.py already auto-fixes the heading-bold issue, so do NOT manually re-add font-weight:bold (that was the earlier mistake — editing by hand missed the h1 and caused conflicts). Still verify the rest against references/wechat-html-guide.md:

  • Headings: confirm the script injected bold (check the output HTML contains font-weight:bold on all h1/h2/h3). No manual edit needed.
  • Rounded corners: 现代微信支持 border-radius 圆角与 box-shadow 阴影(秀米/135 模板大量使用),圆角不会被过滤。如果看到直角,通常是看了旧的/被手动改过的草稿,而非微信清空。
  • Placeholder images: sections such as 【封面图片占位】 must be replaced with real &lt;img&gt; using WeChat-hosted URLs (https://mmbiz.qpic.cn/...) obtained after uploading to the WeChat material library.
  • Layout: avoid flex/grid; use &lt;table&gt; or stacked &lt;section&gt; blocks with inline styles.
  • Edit-mode style loss (坑五, highest-frequency recurrence): if the article looks correct in preview but loses styles after clicking "编辑" (entering the rich-text editor), the core cause is &lt;div&gt; tags — WeChat's editor forces &lt;div&gt;→&lt;p&gt; on entering edit mode and drops most style (so all styling vanishes). The secondary cause is multi-line/indented HTML (whitespace normalization). convert_wechat_html.py now fixes BOTH automatically: all &lt;div&gt;→&lt;section&gt;, and minify to single line. Verify with grep -c &quot;&lt;div&quot; &lt;file&gt; (must be 0) and grep -c $&#x27;\n&#x27; &lt;file&gt; (must be ~1). If a draft was made from an old div-based file, re-run conversion and regenerate.

Re-run Step 1 only if the source changed.

Step 3 — Collect credentials and a cover image

The draft API requires:

  1. AppID + AppSecret of a verified service account, injected as environment variables (never written to disk): WECHAT_APPID, WECHAT_APPSECRET.
  2. A cover image (jpg/png local path) — thumb_media_id is mandatory for drafts.
  3. IP whitelist: the caller's public IP must be added to 公众号后台「开发 → 基本配置 → IP白名单」, or the call fails with 40164.

If the user has not provided a cover image, ask for one before proceeding. If credentials are missing, instruct the user to export them as env vars (PowerShell: $env:WECHAT_APPID=&quot;wx...&quot;; $env:WECHAT_APPSECRET=&quot;...&quot;).

Step 4 — Create the draft

python scripts/create_wechat_draft.py \
  --html &lt;公众号版.html&gt; \
  --cover &lt;封面.jpg&gt; \
  --author &quot;作者名&quot;

The script fetches access_token, uploads the cover (material/add_material) to obtain thumb_media_id, then calls draft/add. On success it prints the media_id.

强烈建议加 --verify:创建后立即用 draft/get 把草稿读回来,逐项报告 font-weight:bold / border-radius 次数与标签保留情况,用数据证明"接口没有丢样式"。当用户反复反馈"样式不对"时,这是排除"接口丢样式"假设的一锤定音手段。

python scripts/create_wechat_draft.py \
  --html &lt;公众号版.html&gt; --cover &lt;封面.jpg&gt; --author &quot;作者名&quot; --verify

Step 5 — Deliver the result

Return the media_id to the user and point them to 公众号后台「内容与互动 → 草稿箱」to preview. Note any remaining placeholder images or square-corner caveats. If styles still look wrong, loop back to Step 2.

Resources

  • scripts/convert_wechat_html.py — sanitizer: strips &lt;script&gt;/&lt;head&gt;/wrappers, strips &lt;a&gt;/class/id + invisible Unicode (anti-45166), keeps inline styles, auto-injects heading bold, converts &lt;div&gt;→&lt;section, unifies spacing, and minifies to single line.
  • scripts/upload_content_images.py — content-image prep: uploads base64/local/external &lt;img&gt; to WeChat via media/uploadimg, compresses >1MB images, rewrites src to mmbiz URL. Requires Pillow (use the managed venv python).
  • scripts/create_wechat_draft.py — draft publisher: token → upload cover → draft/add. Pure stdlib, no pip needed.
  • references/wechat-html-guide.md — full WeChat HTML filtering rules, CSS-reset pitfalls, draft API details, and a security checklist.

Security checklist

  • Never persist AppSecret to files, memory, or git. Use env vars only, and suggest rotating the secret after any exposure.
  • Verify the account is a verified service account with draft API permission before calling.
  • On failure, triage in order: IP whitelist (40164) → account verification (48001) → cover image format/size.

常见问题

5 问
答案由本站依据条目字段整理
微信公众号排版HTML导入助手怎么安装?

在支持 Skills 的客户端里执行:skillhub install user_c0782da5/wechat-html-to-draft。安装方式为未标注。装完刷新技能列表或重开客户端。

微信公众号排版HTML导入助手支持哪些客户端?

资料没有标注宿主客户端,但只要客户端支持 Skills(Claude、Codex、Cursor 等),一般都能加载。

微信公众号排版HTML导入助手权限高吗,安全吗?

权限级别为未标注权限。安装前先看它会读取或写入哪些内容。

微信公众号排版HTML导入助手收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于技能本身和所用的模型或客户端,正式使用前按作者说明确认。

微信公众号排版HTML导入助手用什么许可证?

许可证标注为 未说明(许可证不明确)。商用或二次分发前请到仓库确认条款原文。

热门专题

按场景挑技能
全部专题 →

技能内容以作者仓库为准;分类、权限级别与许可证状态的中文说明为中文整理,最近核验 未标注。