بنقرة واحدة
md2wechat
Publish Markdown/HTML articles to WeChat Official Account (微信公众号) drafts via API with multiple visual styles
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Publish Markdown/HTML articles to WeChat Official Account (微信公众号) drafts via API with multiple visual styles
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | md2wechat |
| description | Publish Markdown/HTML articles to WeChat Official Account (微信公众号) drafts via API with multiple visual styles |
Publish Markdown or HTML content to WeChat Official Account drafts via API, with automatic format conversion and multiple visual styles.
pip install wechatpyacademic_gray (默认): 学术灰风格 - 适合技术文档和学术论文festival: 节日快乐色彩系 - 温暖红金配色,适合节日祝福tech: 科技产品介绍色彩系 - 蓝色科技风,适合产品介绍announcement: 重大事情告知色彩系 - 警示橙红配色,适合重要通知python test_official_api.py
pip install md2wechat
# Configure credentials
cat > .env << EOF
WECHAT_APPID=your_appid_here
WECHAT_APP_SECRET=your_app_secret_here
EOF
# Clone repository
git clone https://github.com/zkkython/md2wechat.git
cd md2wechat
pip install -e .
# Install as Claude skill
mkdir -p ~/.claude/skills
cp -r skills/md2wechat ~/.claude/skills/
# After pip install
md2wechat --markdown /path/to/article.md
md2wechat --html /path/to/article.html
# With style option
md2wechat --markdown article.md --style tech
md2wechat --markdown article.md --style festival --type newspic
# Basic usage
python skills/md2wechat/scripts/publish.py --markdown /path/to/article.md
# With style selection
python skills/md2wechat/scripts/publish.py --markdown article.md --style tech
python skills/md2wechat/scripts/publish.py --markdown article.md --style announcement
# View all options
python skills/md2wechat/scripts/publish.py --help
Once installed in ~/.claude/skills/, use natural language:
Publish this markdown article to WeChat: /path/to/article.md
Use the tech style for this article
| Style | Description | Best For |
|---|---|---|
academic_gray | 学术灰风格,简洁专业 | 技术文档、学术论文 |
festival | 节日快乐色彩系,温暖红金 | 节日祝福、庆祝内容 |
tech | 科技蓝配色,现代感强 | 产品介绍、科技文章 |
announcement | 警示橙红配色,醒目突出 | 重要通知、公告 |
原因:
解决方法:
原因:
解决方法:
wx 开头,例如:wx1234567890abcdef原因:
解决方法:
原因:
解决方法:
原因:
<a href="#xxx">)解决方法:
from skills.md2wechat.scripts.publisher import ArticlePublisher
publisher = ArticlePublisher()
# With default style (academic_gray)
result = publisher.publish("/path/to/article.md")
# With specific style
result = publisher.publish("/path/to/article.md", style="tech")
# With comments enabled
result = publisher.publish(
"/path/to/article.md",
style="tech",
comment_enabled=True,
fans_only_comment=False # True = only fans can comment
)
print(result)
The refactored version uses a modular architecture with MD2WeChat integration:
skills/md2wechat/
├── lib/
│ └── md2wechat/ # MD2WeChat integration (from Mapoet/MD2WeChat)
│ ├── __init__.py
│ └── converter.py # Core Markdown to WeChat HTML converter
└── scripts/
├── publish.py # CLI entry point
├── config.py # Configuration management
├── wechat_client.py # WeChat API client wrapper
├── parsers.py # Markdown/HTML parsers (uses MD2WeChat)
├── image_processor.py # Image upload handler
└── publisher.py # Main publish orchestrator
Markdown File → MD2WeChat Converter → Styled HTML → Image Upload → WeChat Draft
The MD2WeChat converter provides:
Strategy: "API-First Publishing"
Unlike browser-based publishing, this skill uses direct API calls for reliable, fast publishing.
Supported File Formats:
.md files → Parsed by MD2WeChat, styled HTML output.html files → Sent as HTML, formatting preserved# Edit .env file with your WeChat App credentials
cat > .env << EOF
WECHAT_APPID=your_appid_here
WECHAT_APP_SECRET=your_app_secret_here
EOF
Get credentials from: https://mp.weixin.qq.com → Settings → Development → Basic Configuration
Publish Markdown with style:
python skills/md2wechat/scripts/publish.py \
--markdown /path/to/article.md \
--style tech
Available options:
python skills/md2wechat/scripts/publish.py \
--markdown article.md \
--style academic_gray|festival|tech|announcement \
--type news|newspic \
--title "Custom Title" \
--author "Author Name"
# Enable comments
python skills/md2wechat/scripts/publish.py \
--markdown article.md \
--comment
# Enable comments (fans only)
python skills/md2wechat/scripts/publish.py \
--markdown article.md \
--comment --fans-only-comment
Features:
--appid needed (uses WECHAT_APPID from .env)Uses wechatpy SDK to call official WeChat APIs directly.
Authentication: AppID + AppSecret → Access Token (auto-managed by wechatpy)
Key APIs Used:
POST /cgi-bin/token - Get access tokenPOST /cgi-bin/media/upload - Upload imagesPOST /cgi-bin/draft/add - Create draftSee: https://developers.weixin.qq.com/doc/offiaccount/Draft_Box/Add_draft.html
Based on https://github.com/Mapoet/MD2WeChat (MIT License)
Features:
---):
title: Article titledate: Publication datetags: List of tagspermalink: Source URL`code`) → Styled inline...) → With line numbers<title> or <h1> → Article title<img> tags → Images auto-uploaded<p> → Auto-extracted as summaryCause: Invalid credentials or IP not whitelisted Solution: Check WECHAT_APPID and WECHAT_APP_SECRET are correct, and add your server IP to the whitelist in mp.weixin.qq.com
Cause: Article has no images for cover
Solution: Add at least one image to the article (e.g., )
Cause: Account not verified or API permission not granted Solution: Ensure the WeChat account is verified (认证的服务号/订阅号 required for draft API)
Cause: Various WeChat API errors Solution: Check the error message and errcode; refer to https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Global_Return_Code.html
academic_gray for technical contenttech for product announcementsfestival for holiday greetingsannouncement for important noticesA:
A: Check that:
A: This error occurs when:
<a href="#xxx">)Our MD2WeChat converter automatically handles these issues. Make sure you're using the latest version.
A:
A: Ensure images are accessible URLs. Local images are auto-uploaded but may fail if path is incorrect.
A: WeChat limits titles to 64 characters. The script will use the first 64 chars.
A: news is standard article format; newspic (小绿书) is image-focused with limited text.