Md to wechat

From wulaosiji/skills · View interactive version

Md to wechat is an AI agent skill from the GitHub repository wulaosiji/skills. Markdown转微信公众号HTML工具,支持全内联样式、系统字体栈、丰富组件、自定义主题色和元数据,生成微信公众号编辑器兼容的HTML。 Use when: "Markdown转公众号", "生成公众号HTML", "公众号排版工具", "发微信公众号", "公众号样式", "Markdown to WeChat", "WeChat article formatting", "WeChat HTML", "custom theme colors", "WeChat publishing". Cross-references: long-form-writer, image-ocr, info

How to use this skill

Skill file

Markdown to WeChat HTML

将Markdown格式的文章转换为微信公众号编辑器兼容的HTML格式。

When to Use

Use this skill when:

Do NOT use this skill if:

Typical triggers:

Workflow

  1. 探查 (Probe): 完整读取需求指定的 Markdown 输入文件,确认文章标题、副标题、作者、标签等元数据,以及目标主题色和输出路径。
  1. 约束 (Constrain): 验证输入完整性,设定边界:全内联样式(不支持CSS变量和伪元素)、文章不超过2万字、外部图片URL需上传素材库。不降级交付物。
  1. 证据 (Evidence): 每个样式组件的转换规则来自微信公众号编辑器兼容规范。Markdown 语法与公众号样式的映射关系是可复现的转换证据。
  1. 执行 (Execute): 调用转换脚本生成 HTML,先给影响与结论,再给行动和必要证据。

准备Markdown内容

# 文章主标题
## 章节标题
### 小节标题
> 引用内容
- 列表项
| 表格 | 数据 |

配置元数据

converter = MarkdownToWechatConverter(
    title="文章标题",
    subtitle="副标题",
    author="作者名称",
    tags=["标签1", "标签2"]
)

执行转换

./skills/md-to-wechat/scripts/md-to-wechat.sh input.md -o output.html

命令行完整参数

./skills/md-to-wechat/scripts/md-to-wechat.sh input.md \
  -o output.html \
  -t "文章标题" \
  -s "副标题描述" \
  -a "作者名称" \
  --tags "标签1,标签2,标签3"

Python API

from skills.md_to_wechat.md_to_wechat import MarkdownToWechatConverter

converter = MarkdownToWechatConverter(title="文章标题", subtitle="副标题", author="作者", tags=["标签1", "标签2"])
with open('input.md', 'r', encoding='utf-8') as f:
    markdown_text = f.read()
html = converter.convert(markdown_text)
with open('output.html', 'w', encoding='utf-8') as f:
    f.write(html)
  1. 验证 (Verify): 用不同于生成路径的方式回读输出——复制HTML到公众号编辑器预览,在iOS和Android真机上检查显示效果,确认样式兼容。
  1. 交付 (Deliver): 返回生成的 HTML 文件,提示用户上传图片到微信素材库,清理临时文件。

Supported Markdown Syntax

| Markdown | 公众号样式 |

|----------|-----------|

| # 标题 | 文章主标题(封面区域) |

| ## 标题 | 章节标题(带金色装饰线) |

| ### 标题 | 小节标题(带左边框) |

| > 引用 | 引用块(带大引号装饰) |

| **加粗** | 黑色加粗文字 |

| ` 代码 ` | 行内代码(珊瑚色) |

| 代码块 | 深色背景代码块 |

| 表格 | 精美表格(深色表头) |

| - 列表 | 无序列表 |

| 【场景重现】 | 场景卡片(珊瑚色边框) |

| 【结论】 | 结论黑框(深色背景) |

Style Components

Chapter Heading (##): 带金色装饰线的章节标题。

Quote Block (>): 带大引号装饰的引用块,支持作者署名。

> 引用内容
> —— 作者名称

Scene Card(【场景重现】): 特殊标记生成珊瑚色边框的场景卡片。

Conclusion Box(【结论】): 深色背景的结论框。

Theme Colors: 默认使用金色+珊瑚色主题,可自定义。

colors = {
    'primary': '#d4a574', 'accent': '#e07a5f', 'dark': '#2d3436',
    'text': '#1a1a1a', 'text_secondary': '#666', 'bg_light': '#f5f5f5', 'bg_card': '#f8f9fa',
}
converter = MarkdownToWechatConverter(colors=colors)

Output

Guardrails

Anti-patterns:

Limitations

Important Notes

  1. 图片处理: 微信编辑器不支持外部图片URL,需上传到微信素材库
  2. 预览测试: 务必在iOS和Android真机预览
  3. 字数限制: 单篇文章建议不超过2万字
  4. 样式兼容性: 使用全内联样式确保兼容

Workflow Integration

长文 → 公众号

from skills.long_form_writer import expand_outline
from skills.md_to_wechat.md_to_wechat import MarkdownToWechatConverter

markdown_text = expand_outline(outline_path="outline.md")
converter = MarkdownToWechatConverter(title="文章标题", subtitle="副标题", author="作者")
html = converter.convert(markdown_text)
with open("wechat.html", "w", encoding="utf-8") as f:
    f.write(html)

Changelog

Related Skills

About UniqueClub

Part of the UniqueClub toolkit - a collection of skills for AI-powered content creation and automation.

🌐 https://uniqueclub.ai

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.