SuperAPI AI Directory

wechat-publisher

General & other

View repository

Updated 10-16 07:23

About this skill

WeChat Publisher - Official Account Publishing Assistant

One-click formatting and export of completed WPS Notes content into WeChat Official Account HTML format. This is the final step of the creation workflow: the content is complete, and it only needs to be formatted and published.

Use Cases

Typical Workflow:

  1. Use content-creator to create article content
  2. Save to WPS Notes
  3. Use this skill to export the formatted HTML ← You are here
  4. Paste into the Official Account backend and publish directly

Contract

Input Contract

Trigger Conditions:

  • "Post to Official Account"
  • "Format for Official Account"
  • "Export to Official Account"
  • "I want to publish"
  • "Article formatting"
  • "Generate Official Account HTML"
  • "This one is ready to publish"
  • "Help me format it"

Input Types:

  1. WPS Note ID(required): a note whose content is complete
  2. Template Name(optional):default/minimal/elegant, default blue-theme
  3. Output Path(optional): by default generates {标题}_formatted.html

Prerequisites:

  • Note content is complete (not an empty note)
  • The note has been saved and synced to the cloud
  • Content is recommended to be < 20,000 characters

Output Contract

File Description
{标题}_formatted.html Official Account formatted file with inline styles, can be pasted directly into the Official Account editor

Formatting Features:

  • WPS Notes XML directly converted to HTML(no Markdown intermediate layer, higher style precision)
  • WPS preset colors (fontColor / fontHighlightColor) fully mapped to inline styles
  • Code block syntax highlighting
  • Adaptive image handling
  • Mobile reading optimization

Error Contract

Error Scenarios Error Code Handling Method
Note does not exist NOTE_NOT_FOUND Check whether note_id is correct
Note is empty EMPTY_CONTENT Prompt to complete content creation first
Content is too long CONTENT_TOO_LONG Recommend splitting into multiple posts
Image processing failed IMAGE_ERROR Check whether the image link is valid

Tool Priority Strategy

Prefer CLI, fall back to 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 Operation Decision Tree:

用户触发「排版发布」
    │
    ├─ 检测 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"

Quick Start

Method 1: CLI reading + script conversion (recommended)

# 获取当前笔记并导出
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 "文章标题"

Python API

from scripts.export_to_html import WPSNoteExporter

exporter = WPSNoteExporter()
exporter.export(
    note_id="abc123",
    template_name="default",
    output_path="./article.html"
)

Method 2: MCP tool method (fallback when CLI is unavailable)

Read the note content through the wps-note SKILL's MCP tool, then convert it to 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>

Complete MCP Workflow Example

# 步骤 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"

Placeholder Tags (Quick Formatting)

Use these tags in WPS Notes, and they will be automatically converted to the corresponding styles during export:

Tag Usage Effect
<b/> <b/>文字</b> Orange bold (whole paragraph or inline)
<h2/> <h2/>大标题</h2> Blue large heading (level-1 section)
<h3/> <h3/>小标题</h3> Blue small heading (level-2 subsection)
<bq/> <bq/>引用文字</bq> Quote block with gray background and blue border
<note/> <note/>注释文字</note> Gray small-text note

Usage example:

<h2/>01|核心观点

<b/>整段橙色加粗,适合核心金句。</b>

<b/>行内加粗</b> 用于强调重点词汇。

<h3/>深入分析

正文段落正常书写...

<bq/>引用块适合摘录观点或补充说明。</bq>

<note/>注:本文仅代表个人观点。</note>

WPS note color → HTML color mapping

Colors in WPS note XML are constrained by thepreset palette, and are mapped to WeChat inline style RGB values according to the table below during export:

fontColor (font color)

WPS XML value Meaning HTML output
#080F17 Black color: rgb(8,15,23)
#C21C13 Red color: rgb(194,28,19)
#DB7800 Orange color: rgb(219,120,0)
#078654 Green color: rgb(7,134,84)
#0E52D4 Blue color: rgb(14,82,212)
#0080A0 Light blue color: rgb(0,128,160)
#757575 Gray color: rgb(117,117,117)
#DA326B Pink color: rgb(218,50,107)
#D1A300 Gold color: rgb(209,163,0)
#58A401 Light green color: rgb(88,164,1)
#116AF0 Bright blue color: rgb(17,106,240)
#A639D7 Purple color: rgb(166,57,215)

fontHighlightColor (text background highlight)

WPS XML value Meaning HTML output
#FBF5B3 Yellow background-color: rgb(251,245,179); padding:0 2px; border-radius:2px
#F8D7B7 Orange background-color: rgb(248,215,183); ...
#F7C7D3 Pink background-color: rgb(247,199,211); ...
#DFF0C4 Green background-color: rgb(223,240,196); ...
#C6EADD Dark green background-color: rgb(198,234,221); ...
#D9EEFB Blue background-color: rgb(217,238,251); ...
#D5DCF7 Light blue background-color: rgb(213,220,247); ...
#E6D6F0 Purple background-color: rgb(230,214,240); ...
#E6E6E6 Gray background-color: rgb(230,230,230); ...

Note: Any hex color value will be silently discarded in the WPS editor. The export script only handles colors in the above preset palette; other values are ignored and not rendered.


Template styles

Template Features Use cases
blue-theme ⭐Default Blue accent color, modern and concise Technology, enterprise, formal documents
default Orange style, professional and elegant General scenarios
minimal Minimalist style, clean and crisp Technical documentation, tutorials
elegant Elegant and refined, rich in detail In-depth long-form articles, brand content

blue-theme Blue theme

A blue theme based on sample HTML, features:

  • Primary color: rgb(36, 91, 219) Dark blue
  • Body font size: 15px (smaller and more compact than default)
  • Line spacing: 2.0 (more comfortable readability)
  • Quote block: 3px left border + light gray background
  • Columns: Flex layout, center-aligned

How to use:

python scripts/export-to-html.py --note-id "abc123" --template blue-theme

Combination with content-creator

创作流程:

┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│  content-       │     │   WPS 笔记      │     │  wechat-        │
│  creator        │ --> │   (内容完成)   │ --> │  publisher      │
│  (创作内容)    │     │                 │     │  (排版发布)    │
└─────────────────┘     └─────────────────┘     └─────────────────┘
                              你在这里 ↑

Complete example:

# 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 工具介绍"

Conversion process

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
                                      │
                                      └─ 浏览器打开 → 点「复制内容」→ 粘贴到公众号

File structure

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    # 格式规范

Common orchestration patterns

Pattern 1: Directly export the current note

The user already has content, so format and export directly:

# 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

Pattern 2: Search then export

The user does not remember the note ID, so search first and then export:

# CLI 方式(推荐)
python scripts/export-to-html.py --search "文章标题"

# MCP 方式(降级)
search_notes({ keyword: "文章标题" }) → note_id
python scripts/export-to-html.py --note-id <id>

Troubleshooting

CLI unavailable

Symptom:wpsnote-cli Command not found or authentication failed Solution: Automatically fall back to using MCP tools; the process remains unchanged

Note read failed (NOTE_NOT_FOUND)

Symptom:search_notes or get_current_note returns note does not exist Cause: Wrong note ID, note deleted, editor not ready Solution:

  1. Search again to confirm the correct note_id
  2. Check whether the WPS Notes app is open normally
  3. If using get_current_note, make sure the note window is active

Content is empty or formatting is corrupted

Symptom: The exported HTML content is empty or has abnormal formatting Cause: Note XML parsing failed, contains unsupported block types Solution:

  1. Check whether the note actually contains content (it is not an empty note)
  2. Check whether the note contains read-only content such as embed, note_audio_card
  3. Manually check whether the XML structure has abnormal tags

Images cannot be displayed

Symptom: Images in the WeChat Official Account backend appear blank or as red crosses Cause: Image URL is invalid, local images were not correctly converted to base64, image format is not supported Solution:

  1. Network images: Check whether the URL points directly to an image resource (not an HTML page)
  2. Local images: Confirm they have been converted to base64 data URI
  3. Image format: Prefer PNG, JPG, avoid WebP

Placeholder tags do not take effect

Symptom:<b/>、<h2/> and other tags are displayed as plain text in HTML Cause: Incorrect tag format, improper nesting Solution:

  1. Ensure tags are properly closed:<b/>文字</b> ✓ <b/>文字 ✗
  2. Check whether tags are nested inside other tags, causing parsing failure
  3. Refer to the correct usage in the placeholder tags section

Template loading failed

Symptom: After specifying a template, the style does not take effect and the default style is used Cause: Template name misspelled, template file missing, YAML parsing error Solution:

  1. Check the template name spelling (blue-theme、default、minimal、elegant)
  2. Confirm that the templates/ directory contains the corresponding .yaml file
  3. Check whether the template YAML format is correct

Styles are lost after pasting HTML into the WeChat Official Account

Symptom: Local preview is normal, but styles are corrupted after pasting into the WeChat Official Account backend Cause: The WeChat Official Account editor filters some CSS, WeChat built-in browser compatibility issues Solution:

  1. Use inline styles (style="..."), avoid class selectors
  2. Avoid using complex CSS features (use grid and flex with caution)
  3. After previewing in the WeChat Official Account backend, scan the QR code with your phone to view the actual effect

MCP tool call failed

Symptom:mcp__wpsnote__read_note and other tools report errors Cause: EDITOR_NOT_READY, BLOCK_NOT_FOUND, network issues Solution:

  1. Check whether the WPS Notes app is running normally
  2. Retrieve again note_id or block_id
  3. Refer to wps-note SKILL's Troubleshooting

Notes

  1. This is the last step: Only used for notes whose content is already complete, do not create here
  2. CLI preferred:wpsnote-cli Always prefer it when available; it is fast and more stable
  3. Inline code: WPS XML does not support inline code and will convert it to plain text
  4. Content length: If it exceeds 20000 characters, it is recommended to split it into multiple articles
  5. Image handling: Images in WPS Notes src are WPS CDN addresses; when exporting,reference them directly, and WeChat Official Accounts can load them normally; do not perform base64 conversion (uploading local paths to WeChat Official Accounts easily fails)
  6. Image caption: For images with the caption attribute, after export a gray centered small-text caption will be generated below the image
  7. Color constraints: WPS Notes only supports the preset color palette; arbitrary hex values will be silently discarded by the editor; the export script maps to RGB according to the preset palette, and non-preset color values are ignored directly

Resources

  • Format specification:references/format-guide.md
  • Template configuration:templates/
  • Core script:scripts/export-to-html.py
  • MD conversion script:scripts/md_to_html.py