md2wechat

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MD to WeChat Skill (AI Only)

MD 转微信工具(仅AI模式)

Convert Markdown to WeChat Official Account HTML with inline CSS (AI mode) and optionally upload to the draft box.
将Markdown转换为带内联CSS的微信公众号HTML(AI模式),支持可选上传到草稿箱。

Quick Commands

快速命令

bash
undefined
bash
undefined

Render AI-style HTML (theme) from Markdown

Render AI-style HTML (theme) from Markdown

python scripts/md_ai_render.py --md article.md --theme autumn-warm --out article.html
python scripts/md_ai_render.py --md article.md --theme autumn-warm --out article.html

Then publish

Then publish

python scripts/wechat_publish.py --md article.md --html article.html --draft --cover cover.jpg

---
python scripts/wechat_publish.py --md article.md --html article.html --draft --cover cover.jpg

---

Workflow

工作流

  1. Read the Markdown file and note title, images, and structure.
  2. Pick AI theme (see
    references/themes.md
    ).
  3. Render themed HTML and save it to file.
  4. If user wants one-click publish, upload images and create draft with the tool.
  1. 读取Markdown文件,记录标题、图片和结构。
  2. 选择AI主题(参考
    references/themes.md
    )。
  3. 渲染带主题的HTML并保存到文件。
  4. 如果用户需要一键发布,使用工具上传图片并创建草稿。

Render HTML

渲染HTML

bash
python scripts/md_ai_render.py --md article.md --theme autumn-warm --out article.html
bash
python scripts/md_ai_render.py --md article.md --theme autumn-warm --out article.html

Draft Upload (One-Click Publish)

草稿上传(一键发布)

bash
python scripts/wechat_publish.py --md article.md --html article.html --draft --cover cover.jpg
Use the first image as cover if the user does not provide one.
bash
python scripts/wechat_publish.py --md article.md --html article.html --draft --cover cover.jpg
如果用户未提供封面则使用第一张图片作为封面。

Fetch WeChat-Sanitized HTML

获取微信合规HTML

bash
python scripts/wechat_publish.py --md article.md --html article.html --draft --cover cover.jpg --fetch-draft article.wechat.html
bash
python scripts/wechat_publish.py --md article.md --html article.html --draft --cover cover.jpg --fetch-draft article.wechat.html

Images

图片

  • Local/remote images are uploaded to WeChat by the tool during publish.
  • For AI-generated images, insert
    ![alt](__generate:prompt__)
    in Markdown or ask in natural language.
  • For details, read
    references/image-syntax.md
    .
  • 发布过程中工具会自动将本地/远程图片上传到微信。
  • 对于AI生成的图片,在Markdown中插入
    ![alt](__generate:prompt__)
    即可,也可通过自然语言要求生成。
  • 详情请阅读
    references/image-syntax.md

Standalone Image

独立图片

AI image generation is handled by Claude; no separate tool call.
AI图片生成由Claude处理,无需单独调用工具。

Configuration (Env File)

配置(环境变量文件)

Assume the user has an env file (e.g.
.env
) configured with:
  • WECHAT_APPID
  • WECHAT_SECRET
Optional:
  • IMAGE_API_KEY
    (AI images)
  • IMAGE_API_BASE
The publish tool loads
.env
by default; override with
--env
. It also accepts
AppID
/
AppSecret
in the env file. Draft title defaults to the Markdown filename (without
.md
). Override with
--title
.
假设用户已在环境变量文件(如
.env
)中配置了以下参数:
  • WECHAT_APPID
  • WECHAT_SECRET
可选参数:
  • IMAGE_API_KEY
    (AI图片生成)
  • IMAGE_API_BASE
发布工具默认加载
.env
,可通过
--env
参数指定其他环境变量文件。 也支持从环境变量文件中读取
AppID
/
AppSecret
。 草稿标题默认使用Markdown文件名(不带
.md
后缀),可通过
--title
参数覆盖。

Examples

示例

Example 1: Basic Conversion

示例1:基础转换

Input (article.md):
markdown
undefined
输入(article.md):
markdown
undefined

Hello World

Hello World

This is a simple article.
  • Item 1
  • Item 2

**Command**:
```bash
python scripts/md_ai_render.py --md article.md --theme autumn-warm --out article.html
Output (article.html): WeChat-compatible HTML with inline CSS and autumn-warm theme styling.
This is a simple article.
  • Item 1
  • Item 2

**命令**:
```bash
python scripts/md_ai_render.py --md article.md --theme autumn-warm --out article.html
输出(article.html): 适配微信、带内联CSS和autumn-warm主题样式的HTML。

Example 2: Publish to Draft

示例2:发布到草稿

Input: article.md + article.html + cover.jpg
Command:
bash
python scripts/wechat_publish.py --md article.md --html article.html --draft --cover cover.jpg
Output:
json
{"success": true, "image_count": 2, "draft_media_id": "xxx"}
输入: article.md + article.html + cover.jpg
命令:
bash
python scripts/wechat_publish.py --md article.md --html article.html --draft --cover cover.jpg
输出:
json
{"success": true, "image_count": 2, "draft_media_id": "xxx"}

References

参考文档

  • references/themes.md
    (AI themes and prompts)
  • references/html-guide.md
    (WeChat HTML rules)
  • references/image-syntax.md
    (image syntax)
  • references/wechat-api.md
    (draft upload behavior)
  • references/themes.md
    (AI主题和提示词)
  • references/html-guide.md
    (微信HTML规则)
  • references/image-syntax.md
    (图片语法)
  • references/wechat-api.md
    (草稿上传行为)