将Markdown文章转换为美化的HTML格式,适配微信公众号发布。应用专业CSS样式、代码高亮、优化排版。当用户说"美化这篇文章"、"转换为HTML"、"优化公众号格式"、"生成公众号HTML"时使用。
将Markdown文章转换为适合微信公众号的美化HTML,一键生成专业排版。
python scripts/markdown_to_html.py \
--input article.md \
--theme tech \
--preview
python scripts/batch_convert.py \
--input articles/ \
--theme minimal \
--workers 8
python scripts/preview_generator.py \
--input article.md \
--theme business
wechat-article-formatter/
├── SKILL.md # 主技能文档
├── README.md # 本文件
├── EXAMPLES.md # 使用示例
├── requirements.txt # Python依赖
├── test_article.md # 测试文件
│
├── scripts/ # 转换脚本
│ ├── markdown_to_html.py # 主转换脚本
│ ├── batch_convert.py # 批量转换
│ └── preview_generator.py # 实时预览
│
├── templates/ # CSS主题模板
│ ├── tech-theme.css # 科技风主题
│ ├── minimal-theme.css # 简约风主题
│ └── business-theme.css # 商务风主题
│
└── references/ # 参考文档
├── README.md # 文档导航
├── wechat-constraints.md # 平台限制
├── conversion-guide.md # 转换详解
├── publishing-guide.md # 发布指南
└── theme-customization.md # 主题定制
# 安装Python依赖
pip install -r requirements.txt
markdown - Markdown解析beautifulsoup4 - HTML处理cssutils - CSS解析lxml - XML/HTML解析watchdog - 文件监听(实时预览用)Pygments - 语法高亮(可选)# 使用tech主题转换
python scripts/markdown_to_html.py \
--input /path/to/tech-article.md \
--theme tech \
--output /path/to/output.html \
--preview
输出: 带有蓝紫渐变配色、Atom One Dark代码高亮的HTML文件
# 批量转换目录下所有Markdown文件
python scripts/batch_convert.py \
--input /path/to/blog/ \
--output /path/to/output/ \
--theme minimal \
--workers 8
输出: 所有文章转换为简约风格的HTML文件
# 启动实时预览服务
python scripts/preview_generator.py \
--input /path/to/article.md \
--theme business \
--port 8080
效果: 在浏览器中实时预览,保存Markdown文件后刷新即可看到最新效果
用法: python markdown_to_html.py [选项]
选项:
-i, --input INPUT 输入的Markdown文件路径(必需)
-o, --output OUTPUT 输出的HTML文件路径(可选,默认与输入同名)
-t, --theme THEME 主题选择: tech, minimal, business(默认:tech)
-p, --preview 转换后在浏览器中打开预览
-h, --help 显示帮助信息
用法: python batch_convert.py [选项]
选项:
-i, --input INPUT 输入的Markdown文件或目录路径(必需)
-o, --output OUTPUT 输出目录(可选,默认与源文件同目录)
-t, --theme THEME 主题选择: tech, minimal, business(默认:tech)
-r, --recursive 递归查找子目录中的Markdown文件
-w, --workers NUM 并发转换的线程数(默认:4)
-q, --quiet 静默模式,只显示摘要
-h, --help 显示帮助信息
用法: python preview_generator.py [选项]
选项:
-i, --input INPUT 输入的Markdown文件路径(必需)
-o, --output OUTPUT 输出目录(默认:./preview/)
-t, --theme THEME 主题选择: tech, minimal, business(默认:tech)
-p, --port PORT HTTP服务器端口(默认:8000)
--no-browser 不自动打开浏览器
-h, --help 显示帮助信息
转换Markdown为HTML
python scripts/markdown_to_html.py --input article.md --theme tech --preview
本地预览检查
复制到微信编辑器
Ctrl+A 全选Ctrl+C 复制处理图片
调整格式
手机端预览
发布
详细发布流程请参考 publishing-guide.md
复制现有主题文件
cp templates/tech-theme.css templates/my-theme.css
修改CSS变量
:root {
--primary-color: #10b981; /* 改为绿色 */
--secondary-color: #14b8a6;
}
使用自定义主题
python scripts/markdown_to_html.py --input article.md --theme my
详细自定义指南请参考 theme-customization.md
详细限制说明请参考 wechat-constraints.md
更多问题请参考 wechat-constraints.md 的故障排除章节
本skill基于以下开源项目:
本项目为Claude Code Skill,供个人和商业使用。
祝你使用愉快! 🎉
如有问题或建议,欢迎反馈!
npx skills add BND-1/wechat-article-formatter下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Generate or edit images via Gemini 3 Pro Image (Nano Banana Pro).
Batch-generate images via OpenAI Images API. Random prompt sampler + `index.html` gallery.
Generate spectrograms and feature-panel visualizations from audio with the songsee CLI.
Extract frames or short clips from videos using ffmpeg.
Search GIF providers with CLI/TUI, download results, and extract stills/sheets.
Category:media-generate