htmlwecha
Installation
Review the source and dependencies with a prompt.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "htmlwecha" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-808ccc8797fc3639a7b223e42d23d785528cd2be4c7c0375f1b6da84259c62b6. Verify the upstream source and version against https://skillhub.cn/skills/org-5ott9gs6/htmlwecha before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Download permission for this version is unverified or restricted.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
A converter that transforms WeChat article HTML into a WeChat-compatible format and converts MP4 videos into GIFs to replace specified images.
Introduction source: third_party · org-5ott9gs6 · 1.0.2 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Software, accounts and paid services
- Translation pending; see source documentation.
- Limits and differences
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
A verified file list is not available on Skillπ yet.
Browse files at the source ↗Frontmatter
name: wechat-article
description: 将公众号文章 HTML 转换为微信公众号兼容格式,并把 MP4 视频转成 GIF 替换指定图片。
type: prompt
whenToUse: 当用户需要将微信公众号文章 HTML 按微信规范改造、把视频转成动图替换图片、或要求兼容微信公众号排版时调用本 Skill。
disableModelInvocation: false
arguments:
- html_path
- mp4_path
- gif_width微信公众号文案兼容改造工作流
本 Skill 用于把普通 HTML 文案改造为微信公众号可识别的安全格式,并支持将 MP4 视频转换为 GIF 后替换文案中的图片。
前置依赖
运行环境需要 Python 3.10+,并安装以下包(建议在项目内建 venv):
python3 -m venv .venv
.venv/Scripts/pip install beautifulsoup4 lxml imageio imageio-ffmpeg pillow
脚本还需要 Google Chrome 来完成一件事:
- 把正文 SVG 插画渲染为 PNG(微信编辑器粘贴时不保留 SVG)。
底部联系卡片不再渲染为 GIF,而是直接嵌入项目内已验证微信兼容的 contact_card.html(整体缩放 90%),保留其 base64 GIF 动效。旧版 智银长河公众号联系方式卡片.html 仍兼容。
脚本会自动查找常见安装路径下的 chrome.exe。
核心规范(来自《公众号文案编码规范》)
- HTML 标签白名单:
<section>、<p>、<h3>-<h6>、<ul>/<ol>/<li>、<strong>/<em>、<img>、<a>、<hr>、<mpvoice>/<mpvideo>。- 避免使用
<div>与<span>,可用<section>、<strong>替代。 <h1>、<h2>发布后可能被转为<p>,建议改用<h3>并加内联样式。
- 避免使用
- CSS 必须内联:所有样式写在
style="..."中;<style>、class、id 选择器均会被微信过滤。 - 安全 CSS 属性:
color、font-size、line-height、margin、padding、background-color、width、height、text-align、border-radius、border、display等。- 颜色必须使用
#RRGGBB,不使用 RGB/HSL;渐变会被过滤,需用近似纯色替换。 - 单位统一使用
px;内容最大宽度677px。
- 颜色必须使用
- 布局替代:
flex/grid在微信中不稳定,应改为table或inline-block布局。 - 动态效果:CSS 动画会被过滤,应使用 SVG 白名单动画:
<animate>(x/y/width/height/opacity/d/points/stroke-dashoffset/fill/stroke)、<set>(visibility)、<animateTransform>(translate)。 - 全文背景:使用“零高容器”实现:
height:0;overflow:visible+ 内部position:absolute的<div>铺满背景色。 - 图片资源:
- 本脚本会把所有图片(含生成的 GIF、本地 PNG/JPG、以及 Chrome 渲染出的 SVG 插画)转为 base64 内联,这样从浏览器全选复制再粘贴到微信编辑器时,图片可以一起被粘贴进去。
- 最终发布前,仍建议在微信后台把图片重新上传,换成
mmbiz.qpic.cn域名链接,以获得更稳定的 CDN 分发。
工作步骤
- 备份原文案:若输入文件不是
.bak,脚本会先复制${html_path}.bak作为备份。 - MP4 转 GIF(如提供了
$mp4_path):- 使用 imageio + imageio-ffmpeg 读取视频。
- 按
$gif_width等比缩放,按目标 fps 采样帧,量化到 128 色调色板。 - 生成
$gif_path(默认demo.gif)。
- 修改 HTML 兼容微信:
- 提取所有
data:imagebase64 图片为临时本地 PNG/JPG 文件,便于后续统一处理。 - 若通过
--replace-img-alt或--replace-img-index指定了目标,才把生成的 GIF 替换到对应图片位置;未指定则不替换,仅生成 GIF。 - 用 Chrome headless 把正文 SVG 插画渲染为 PNG,并替换为
<img>标签(微信编辑器粘贴时不支持 SVG)。 - 仅当输入文件名包含「智银长河」时,才读取项目内已验证微信兼容的
contact_card.html(或旧版智银长河公众号联系方式卡片.html),对其所有内联 px 尺寸整体缩放 90%(边框 1px 保持不变),将缩放后的卡片直接替换原版<div class="wx-card">。卡片内已包含 base64 GIF 动效(顶部闪光条、分隔点、红心、二维码扫描线),无需再生成整体 GIF。非智银长河文章会直接移除<div class="wx-card">。 - 删除
<style>、<script>及所有class/id。 - 将
<div>改为<section>;<span class="brand">改为<strong>;<h1>/<h2>改为<h3>并内联样式。 - 将
.compare的 grid 改为<table>。 - 所有颜色转为十六进制,渐变用近似纯色替代,样式全部内联。
- 最后生成两个版本:base64 内联版(独立可查看)和
_local.html(同样已内联 base64,推荐复制粘贴到微信编辑器时使用)。
- 提取所有
- 验证:用 Chrome headless 或打开浏览器检查渲染效果,确保排版、背景、尺寸、动态效果与原文案一致。
- 交付:返回修改后的 HTML 文件、GIF 动图、以及落地的图片文件。
快速调用
在项目目录下执行:
# 1. 创建虚拟环境并安装依赖
python3 -m venv .venv
.venv/Scripts/pip install beautifulsoup4 lxml imageio imageio-ffmpeg pillow
# 2. 运行转换脚本(默认参数对应本项目)
.venv/Scripts/python transform.py
脚本默认处理:
- 输入:
智银长河公众号文章1(1).html.bak - 输出:
智银长河公众号文章1(1).html(base64 内联版) - 输出:
智银长河公众号文章1(1)_local.html(base64 内联版,推荐复制粘贴到微信编辑器时使用) - 视频:
dbeb33c26f2cb68f9636cff14095ea0d.mp4→demo.gif(宽度 677px) - 替换:默认不替换图片;如需替换,通过
--replace-img-alt指定 alt,或通过--replace-img-index 1指定第几张图 - 底部:若输入文件名包含「智银长河」,则读取
contact_card.html(或旧版中文名),整体缩放 90% 后直接嵌入文章末尾,保留 base64 GIF 动效
如需处理其他文件,使用命令行参数:
.venv/Scripts/python transform.py 你的文章.html 你的视频.mp4 --gif-width 677 --gif-path demo.gif
# 如需替换某张图为 GIF
.venv/Scripts/python transform.py 你的文章.html 你的视频.mp4 --gif-width 677 --gif-path demo.gif --replace-img-alt "数据导入界面"
# 或者直接按图片序号替换(从 1 开始)
.venv/Scripts/python transform.py 你的文章.html 你的视频.mp4 --replace-img-index 1
注意事项
- 由于微信编辑器会再次过滤/重写样式,最终发布前务必在公众号助手 APP 或第三方编辑器(如壹伴助手、小墨鹰)中预览。
- 本脚本已将所有图片转为 base64 内联。从浏览器全选复制 → 粘贴到微信编辑器时,静态 PNG/JPG 通常可正常带入,GIF 也能作为图片带入。
- 底部联系卡片现在是一段完整的内联 HTML,直接复制粘贴到微信编辑器即可。卡片内的顶部闪光条、分隔点、红心、二维码扫描线均为 base64 GIF,动效会被保留;微信编辑器预览区有时不自动播放 GIF,发布后在手机端查看通常可正常播放。
- 微信编辑器对浏览器直接粘贴的图片支持不稳定,若粘贴后图片不显示,最可靠的方式是:先粘贴 HTML 结构,再在微信编辑器中手动上传
demo.gif、svg_illustration.png、screenshot2.png、screenshot3.png替换对应位置。 - 复杂的 CSS 动画(如卡片整体入场、悬停)无法在微信内保留,已以静态样式替代。
参考文件
- 本 Skill 目录:
${KIMI_SKILL_DIR} - 转换脚本:
${KIMI_SKILL_DIR}/transform.py - 规则摘要:
${KIMI_SKILL_DIR}/wechat-rules.md
Current listing version
1.0.2
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 针对微信公众号文章 HTML 兼容改造和视频转 GIF 替换图片,解决内容创作者的实际痛点
- 具有明确的受众群体和广泛的应用场景
Highlights
- 触发词描述清晰,覆盖多种变体,边界明确
Highlights
- Phase/步骤清晰,有出口条件,含端到端示例
- frontmatter 完整,单文件未超过 500 行
Highlights
- 工具来源明确,参数正确,覆盖主要异常
- 不可逆操作有确认机制
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 23, 77
Security rating and access scope
risk · Static evidence review; not a runtime safety guarantee.
Translation pending; see source documentation.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.