From learning-skills
Exports WPS notes to inline-styled HTML for WeChat public account publishing. Triggers on phrases like '发公众号', '排版公众号'; uses Python scripts or MCP tools for templates, styles, and images.
npx claudepluginhub wpsnote/wpsnote-skills --plugin learning-skillsThis skill uses the workspace's default tool permissions.
将已完成的 WPS 笔记内容,一键排版并导出为微信公众号 HTML 格式。这是创作流程的最后一步:内容已完成,只需排版发布。
Bulk imports local documents from Obsidian vaults, SiYuan notes, WeChat archives, downloads, or directories into WPS Notes. Supports HTML, Markdown, PDF, DOCX, PPTX, XLSX with images and rich text. Triggers on import requests to WPS Notes.
Posts articles or image-text content to WeChat Official Accounts via API or Chrome CDP. Supports HTML, Markdown, plain text input, and multiple images for 图文/贴图.
Posts articles from HTML, Markdown, or plain text and image-text content with multiple images to WeChat Official Accounts via API or Chrome CDP. Converts Markdown external links to bottom citations.
Share bugs, ideas, or general feedback.
将已完成的 WPS 笔记内容,一键排版并导出为微信公众号 HTML 格式。这是创作流程的最后一步:内容已完成,只需排版发布。
典型工作流:
content-creator 创作文章内容触发条件:
输入类型:
default/minimal/elegant,默认 blue-theme{标题}_formatted.html前置条件:
| 文件 | 说明 |
|---|---|
{标题}_formatted.html | 带内联样式的公众号排版文件,可直接粘贴到公众号编辑器 |
排版特性:
| 错误场景 | 错误码 | 处理方式 |
|---|---|---|
| 笔记不存在 | NOTE_NOT_FOUND | 检查 note_id 是否正确 |
| 笔记为空 | EMPTY_CONTENT | 提示先完成内容创作 |
| 内容过长 | CONTENT_TOO_LONG | 建议拆分为多篇发布 |
| 图片处理失败 | IMAGE_ERROR | 检查图片链接有效性 |
优先使用 CLI,降级到 MCP:
检查 wpsnote-cli 是否可用
↓ 可用(推荐路径)
wpsnote-cli current / find → 获取笔记 ID
wpsnote-cli read --note_id <id> --json → 获取笔记内容(XML)
↓ CLI 不可用(命令不存在 / 认证失败)
[降级] MCP: get_current_note / search_notes
[降级] MCP: read_note
AI 操作决策树:
用户触发「排版发布」
│
├─ 检测 wpsnote-cli
│ ↓ 可用
│ ① 无 note_id → wpsnote-cli current --json
│ 有 note_id → 直接跳到 ③
│ ↓ 不可用
│ ① 无 note_id → MCP: get_current_note()
│
├─ ② 搜索确认(用户给了关键词)
│ CLI: wpsnote-cli find --keyword "xxx" --json
│ MCP: search_notes({ keyword: "xxx" })
│
├─ ③ 读取笔记内容
│ CLI: wpsnote-cli read --note_id <id> --json
│ MCP: read_note({ note_id: <id> })
│
└─ ④ 执行导出脚本
python scripts/export-to-html.py --note-id <id>
→ 生成 "{标题}_formatted.html"
# 获取当前笔记并导出
python scripts/export-to-html.py --current
# 通过 note_id 直接导出
python scripts/export-to-html.py --note-id "abc123"
# 指定模板风格
python scripts/export-to-html.py --note-id "abc123" --template "elegant"
# 搜索笔记并导出
python scripts/export-to-html.py --search "文章标题"
from scripts.export_to_html import WPSNoteExporter
exporter = WPSNoteExporter()
exporter.export(
note_id="abc123",
template_name="default",
output_path="./article.html"
)
通过 wps-note SKILL 的 MCP 工具读取笔记内容,再转换为 HTML:
# 1. 搜索并获取笔记
search_notes({ keyword: "文章标题" }) → note_id
# 2. 读取笔记内容
read_note({ note_id }) → xml_content
# 3. 转换为 HTML(本地脚本处理)
python scripts/export-to-html.py --note-id <id>
# 步骤 1:获取当前笔记(或搜索)
get_current_note()
→ { note_id: "abc123", title: "AI 工具介绍", word_count: 3500 }
# 步骤 2:读取笔记内容(根据大小选择方式)
get_note_outline({ note_id: "abc123" })
→ blocks: [...]
read_note({ note_id: "abc123" })
→ xml_content: "<h1>AI 工具介绍</h1><p>...</p>"
# 步骤 3:导出为 HTML(本地脚本转换)
python scripts/export-to-html.py --note-id "abc123" --template blue-theme
→ 生成 "AI 工具介绍_formatted.html"
在 WPS 笔记中使用这些标签,导出时自动转换为对应样式:
| 标签 | 用法 | 效果 |
|---|---|---|
<b/> | <b/>文字</b> | 橙色加粗(整段或行内) |
<h2/> | <h2/>大标题</h2> | 蓝色大标题(一级章节) |
<h3/> | <h3/>小标题</h3> | 蓝色小标题(二级分节) |
<bq/> | <bq/>引用文字</bq> | 灰底蓝边引用块 |
<note/> | <note/>注释文字</note> | 灰色小字注释 |
使用示例:
<h2/>01|核心观点
<b/>整段橙色加粗,适合核心金句。</b>
<b/>行内加粗</b> 用于强调重点词汇。
<h3/>深入分析
正文段落正常书写...
<bq/>引用块适合摘录观点或补充说明。</bq>
<note/>注:本文仅代表个人观点。</note>
WPS 笔记的 XML 中颜色受预设色板约束,导出时按下表映射为公众号内联样式 RGB 值:
| WPS XML 值 | 含义 | HTML 输出 |
|---|---|---|
#080F17 | 黑色 | color: rgb(8,15,23) |
#C21C13 | 红色 | color: rgb(194,28,19) |
#DB7800 | 橙色 | color: rgb(219,120,0) |
#078654 | 绿色 | color: rgb(7,134,84) |
#0E52D4 | 蓝色 | color: rgb(14,82,212) |
#0080A0 | 浅蓝 | color: rgb(0,128,160) |
#757575 | 灰色 | color: rgb(117,117,117) |
#DA326B | 粉色 | color: rgb(218,50,107) |
#D1A300 | 金色 | color: rgb(209,163,0) |
#58A401 | 浅绿 | color: rgb(88,164,1) |
#116AF0 | 亮蓝 | color: rgb(17,106,240) |
#A639D7 | 紫色 | color: rgb(166,57,215) |
| WPS XML 值 | 含义 | HTML 输出 |
|---|---|---|
#FBF5B3 | 黄色 | background-color: rgb(251,245,179); padding:0 2px; border-radius:2px |
#F8D7B7 | 橙色 | background-color: rgb(248,215,183); ... |
#F7C7D3 | 粉色 | background-color: rgb(247,199,211); ... |
#DFF0C4 | 绿色 | background-color: rgb(223,240,196); ... |
#C6EADD | 深绿 | background-color: rgb(198,234,221); ... |
#D9EEFB | 蓝色 | background-color: rgb(217,238,251); ... |
#D5DCF7 | 浅蓝 | background-color: rgb(213,220,247); ... |
#E6D6F0 | 紫色 | background-color: rgb(230,214,240); ... |
#E6E6E6 | 灰色 | background-color: rgb(230,230,230); ... |
注意:任意 hex 色值在 WPS 编辑器中会被静默丢弃,导出脚本只处理上述预设色板中的颜色,其他值忽略不渲染。
| 模板 | 特点 | 适用场景 |
|---|---|---|
blue-theme ⭐默认 | 蓝色强调色,现代简洁 | 科技、企业、正式文档 |
default | 橙色风格,专业美观 | 通用场景 |
minimal | 极简风格,干净利落 | 技术文档、教程 |
elegant | 优雅精致,细节丰富 | 深度长文、品牌内容 |
基于样本 HTML 的蓝色主题,特点:
rgb(36, 91, 219) 深蓝色使用方法:
python scripts/export-to-html.py --note-id "abc123" --template blue-theme
创作流程:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ content- │ │ WPS 笔记 │ │ wechat- │
│ creator │ --> │ (内容完成) │ --> │ publisher │
│ (创作内容) │ │ │ │ (排版发布) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
你在这里 ↑
完整示例:
# 1. 创作内容
python scripts/create-content.py --topic "AI 工具介绍"
# 2. 写入 WPS
python scripts/wps-write.py --input draft.md --title "AI 工具介绍"
# 3. 排版发布(本 skill)
python scripts/export-to-html.py --search "AI 工具介绍"
WPS 笔记 XML
│
├─ 占位符处理(<b/> <h2/> <bq/> <note/>)
│
├─ xml_to_html():逐块渲染
│ ├─ <h1>/<h2> → <h2 style="...蓝色...">
│ ├─ <h3>-<h6> → <p><span style="...蓝色...">
│ ├─ <p> → <p><span style="...灰色正文...">
│ ├─ <p listType> → 橙色圆点 / 橙色数字列表
│ ├─ <blockquote> → 灰底蓝边引用块
│ ├─ <codeblock> → 语法高亮代码框
│ ├─ <table> → 蓝色表头表格
│ ├─ <highlightBlock>→ 高亮提示块(保留 WPS 配色)
│ ├─ <columns> → Flex 分栏
│ ├─ <span fontColor>→ WPS 预设颜色 → RGB 内联样式
│ └─ <strong>/<em> → 加粗 / 斜体
│
└─ 套入 template.html 壳 → {标题}_formatted.html
│
└─ 浏览器打开 → 点「复制内容」→ 粘贴到公众号
wechat-publisher/
├── SKILL.md # 本文件
├── scripts/
│ ├── export-to-html.py # 核心导出脚本(WPS XML → HTML 直接转换)
│ └── md_to_html.py # 独立 MD 转 HTML 脚本(本地 .md 文件用)
├── templates/
│ ├── template.html # HTML 输出壳(含复制按钮)
│ ├── preview.html # 排版样例(各元素效果预览)
│ ├── default.yaml # 默认模板(橙色风格)
│ ├── blue-theme.yaml # 蓝色主题模板
│ ├── minimal.yaml # 极简模板
│ └── elegant.yaml # 优雅模板
└── references/
└── format-guide.md # 格式规范
用户已有内容,直接排版导出:
# CLI 方式(推荐)
python scripts/export-to-html.py --current --template blue-theme
# MCP 方式(降级)
get_current_note() → note_id
python scripts/export-to-html.py --note-id <id> --template blue-theme
用户不记得笔记 ID,先搜索再导出:
# CLI 方式(推荐)
python scripts/export-to-html.py --search "文章标题"
# MCP 方式(降级)
search_notes({ keyword: "文章标题" }) → note_id
python scripts/export-to-html.py --note-id <id>
现象:wpsnote-cli 命令未找到或认证失败
解决:自动降级使用 MCP 工具,流程不变
现象:search_notes 或 get_current_note 返回笔记不存在
原因:笔记 ID 错误、笔记被删除、编辑器未就绪
解决:
note_idget_current_note,确保笔记窗口是激活状态现象:导出的 HTML 内容为空或格式异常 原因:笔记 XML 解析失败、包含不支持的 block 类型 解决:
现象:公众号后台图片显示为空白或红叉 原因:图片 URL 失效、本地图片未正确转 base64、图片格式不支持 解决:
现象:<b/>、<h2/> 等标签在 HTML 中显示为纯文本
原因:标签格式错误、嵌套不当
解决:
<b/>文字</b> ✓ <b/>文字 ✗现象:指定模板后样式未生效,使用默认样式 原因:模板名称拼写错误、模板文件缺失、YAML 解析错误 解决:
blue-theme、default、minimal、elegant)templates/ 目录存在对应 .yaml 文件现象:本地预览正常,但粘贴到公众号后台样式错乱 原因:公众号编辑器过滤部分 CSS、微信内置浏览器兼容性问题 解决:
style="..."),避免 class 选择器现象:mcp__wpsnote__read_note 等工具报错
原因:EDITOR_NOT_READY、BLOCK_NOT_FOUND、网络问题
解决:
note_id 或 block_idwps-note SKILL 的 Troubleshootingwpsnote-cli 可用时总是首选,速度快且更稳定src 是 WPS CDN 地址,导出时直接引用,微信公众号可正常加载;不做 base64 转换(本地路径上传公众号容易失败)caption 属性的图片,导出后会在图片下方生成灰色居中小字说明references/format-guide.mdtemplates/scripts/export-to-html.pyscripts/md_to_html.py