一、用途 wechat-styler 用于把 Markdown 文章转换为微信公众号可用的内联样式 HTML,输出可直接复制粘贴到公众号编辑器,并尽量降低背景色丢失、图片偏移等兼容问题。
二、主要能力
- 多主题:kami(默认,纸感)、magazine-ink/indigo/forest/kraft/dune(电子杂志系列)、elegant(优雅复古)、modern(现代简约)、minimal(极简主义)。
- 每个主题绑定独立的 Markdown 渲染人格(如 kami-document、magazine-editorial、elegant-essay、modern-technical、minimal-notes),不只换颜色,还控制标题、引用、列表、代码、图注的结构与间距。
- 输出全内联样式,背景色使用 solid hex,并在外层、内容层、文本层重复声明 background-color;图片同时用父级 text-align:center 与自身 margin:0 auto 居中。
三、使用方式 基础用法:/wechat-styler path/to/article.md 指定主题:/wechat-styler path/to/article.md --theme magazine-ink 批量转换:/wechat-styler "articles/*.md" --theme kami 自定义参数:/wechat-styler path/to/article.md --theme kami --font-size 17 --accent-color "#1B365D" 输出到指定路径:/wechat-styler path/to/article.md --output path/to/output.html 参数包括 --theme(默认 kami)、--font-size(默认 16)、--line-height(默认 1.55)、--accent-color(默认 #1B365D)、--background-color(默认 #f5f4ed)、--max-width(默认 640)、--output。默认输出为同名 _wechat.html 文件。 主题预览:node scripts/generate-preview.mjs [article.md] [--themes kami,elegant] [--output path/to/my-preview.html]。 扩展主题:在 themes/ 目录新增 YAML 配置文件后通过 --theme 引用,示例字段见资料给出的 themes/my-theme.yaml。
四、适用场景 公众号深度文章、商业分析与案例、课程与正式说明文、科技教程与快讯、个人随笔、艺术评论等 Markdown 排版需求。
五、限制与注意 需 Node.js 18+,依赖 marked 与 js-yaml,核心脚本为 scripts/convert.mjs。保留原始图片链接,需保证图床可访问;字体均带回退栈。收费、价格、平台支持等资料未提供。主题预览之外的在线托管、自动发布等能力暂未提供。