wechat-styler
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWeChat Styler - 公众号排版工具
WeChat Styler - WeChat Official Account Typesetting Tool
将 Markdown 文章转换为优雅的公众号 HTML 格式,支持多主题切换。
Convert Markdown articles into elegant HTML format for WeChat Official Accounts, supporting multi-theme switching.
使用方式
Usage
bash
undefinedbash
undefined基础用法(使用默认主题)
Basic Usage (Use Default Theme)
/wechat-styler path/to/article.md
/wechat-styler path/to/article.md
指定主题
Specify Theme
/wechat-styler path/to/article.md --theme kami
/wechat-styler path/to/article.md --theme magazine-ink
/wechat-styler path/to/article.md --theme kami
/wechat-styler path/to/article.md --theme magazine-ink
批量转换(支持 glob 模式)
Batch Conversion (Supports Glob Pattern)
/wechat-styler "articles/.md" --theme kami
/wechat-styler "01_项目/内容创作/**/.md" --theme magazine-ink
/wechat-styler "articles/.md" --theme kami
/wechat-styler "01_项目/内容创作/**/.md" --theme magazine-ink
自定义参数
Custom Parameters
/wechat-styler path/to/article.md --theme kami --font-size 17 --accent-color "#1B365D"
/wechat-styler path/to/article.md --theme kami --font-size 17 --accent-color "#1B365D"
输出到指定路径(单文件)
Output to Specified Path (Single File)
/wechat-styler path/to/article.md --output path/to/output.html
undefined/wechat-styler path/to/article.md --output path/to/output.html
undefined可用主题
Available Themes
1. kami(紙感编辑排版)- 默认主题
1. kami (Paper-Style Typesetting) - Default Theme
特点:
- warm parchment 纸感背景:
#f5f4ed - ink-blue 单一强调色:
#1B365D - 中文标题使用衬线/楷体栈,正文使用稳定无衬线栈
- 温暖灰阶,不使用冷灰和纯白大底
- 标题左侧蓝色竖线、solid tag 背景、克制引用块
- 所有背景色使用 solid hex,并在外层、内容层、文本层重复声明,降低粘贴到公众号后背景丢失风险
适用场景: 公众号深度文章、商业分析、课程内容、正式说明文
参数:
yaml
font_family_cn: 'Inter','TsangerJinKai02','Source Han Sans SC','Noto Sans CJK SC','PingFang SC','Microsoft YaHei',Arial,sans-serif
font_family_en: 'Newsreader','Source Serif 4','Source Serif Pro','Charter',Georgia,'Times New Roman',serif
font_size: 16
line_height: 1.55
accent_color: '#1B365D'
background_color: '#f5f4ed'
surface_color: '#faf9f5'
text_color: '#141413'
secondary_color: '#5e5d59'
heading_font: 'TsangerJinKai02','Source Han Serif SC','Noto Serif CJK SC','Songti SC','STSong',Georgia,serif
code_font: 'JetBrains Mono','SF Mono','Fira Code',Consolas,Monaco,'TsangerJinKai02','Source Han Serif SC',monospaceFeatures:
- Warm parchment paper-style background:
#f5f4ed - Ink-blue single accent color:
#1B365D - Chinese headings use a serif/regular script font stack, body text uses a stable sans-serif font stack
- Warm grayscale palette, no cold gray or pure white large backgrounds
- Blue vertical line on the left of headings, solid tag background, restrained quote blocks
- All background colors use solid hex values, and are declared repeatedly in outer layers, content layers, and text layers to reduce the risk of background loss after pasting into the official account
Applicable Scenarios: In-depth official account articles, business analysis, course content, formal explanatory texts
Parameters:
yaml
font_family_cn: 'Inter','TsangerJinKai02','Source Han Sans SC','Noto Sans CJK SC','PingFang SC','Microsoft YaHei',Arial,sans-serif
font_family_en: 'Newsreader','Source Serif 4','Source Serif Pro','Charter',Georgia,'Times New Roman',serif
font_size: 16
line_height: 1.55
accent_color: '#1B365D'
background_color: '#f5f4ed'
surface_color: '#faf9f5'
text_color: '#141413'
secondary_color: '#5e5d59'
heading_font: 'TsangerJinKai02','Source Han Serif SC','Noto Serif CJK SC','Songti SC','STSong',Georgia,serif
code_font: 'JetBrains Mono','SF Mono','Fira Code',Consolas,Monaco,'TsangerJinKai02','Source Han Serif SC',monospace2. magazine 系列(电子杂志 × 电子墨水)
2. magazine Series (E-Magazine × E-Ink)
从 迁移来的 5 套预设,保留 的杂志色彩关系,同时改造成微信公众号安全 HTML:不使用 ,所有背景色均为 solid hex。
magazine-web-pptink / paper / tintrgba()| 主题 | 命令 | 变体 | 字体 / 版式人格 |
|---|---|---|---|
| 墨水经典 | | | 无衬线正文 + 衬线标题,细 rule、dash list、pull quote,通用杂志内页 |
| 靛蓝瓷 | | | Inter/SF Pro 正文 + Source Serif 标题,左侧研究栏、note quote、技术代码块 |
| 森林墨 | | | 楷体/宋体正文 + 非虚构标题,居中标题、field note 引用、自然图片说明 |
| 牛皮纸 | | | 宋体正文 + archive 标题盒,档案式引用、罗马数字有序列表、旧纸代码框 |
| 沙丘 | | | Avenir 正文 + Didot/Bodoni 标题,右对齐画廊标题、gallery quote、极简图片说明 |
共同特点:
- 每个主题都有独立字体栈、字号、行距、段距、标题结构、列表 marker、引用块、代码块和图片说明。
- 分隔以留白、短淡线和局部标识为主;不会在每个章节之间自动插入整宽实线。
- 五个主题共享 renderer 入口,但通过
magazine-editorial走不同结构分支,不只是替换颜色。magazine_variant - 所有背景色都使用 solid hex,并在区块与文本 span 上重复声明 ,降低复制到公众号编辑器后背景色丢失的概率。
background-color - 图片自身带 居中兜底,避免公众号编辑器复制后改写图片宽度导致图片靠左。
margin:0 auto - 版式保留杂志感,但输出仍完全内联,可直接复制到公众号编辑器。
5 presets migrated from , retaining the magazine color relationship of , while transformed into WeChat Official Account-safe HTML: no is used, all background colors are solid hex values.
magazine-web-pptink / paper / tintrgba()| Theme | Command | Variant | Font / Layout Personality |
|---|---|---|---|
| Ink Classic | | | Sans-serif body text + serif headings, thin rules, dash lists, pull quotes, universal magazine inner pages |
| Indigo Porcelain | | | Inter/SF Pro body text + Source Serif headings, left research bar, note quotes, technical code blocks |
| Forest Ink | | | Regular script/Songti body text + non-fiction headings, centered headings, field note quotes, natural image captions |
| Kraft Paper | | | Songti body text + archive title boxes, archive-style quotes, Roman numeral ordered lists, old paper code boxes |
| Dune | | | Avenir body text + Didot/Bodoni headings, right-aligned gallery headings, gallery quotes, minimalist image captions |
Common Features:
- Each theme has independent font stacks, font sizes, line heights, paragraph spacing, heading structures, list markers, quote blocks, code blocks, and image captions.
- Separation mainly uses white space, short light lines, and local identifiers; no full-width solid lines are automatically inserted between chapters.
- The five themes share the renderer entry, but follow different structural branches through
magazine-editorial, not just color replacement.magazine_variant - All background colors use solid hex values, and is declared repeatedly on blocks and text spans to reduce the probability of background color loss after copying to the official account editor.
background-color - Images have centered fallback to avoid left alignment caused by the official account editor rewriting image width after copying.
margin:0 auto - The layout retains magazine feel, but the output is fully inline and can be directly copied to the official account editor.
3. elegant(优雅复古)
3. elegant (Elegant Retro)
特点:
- 中文:方正书宋(FZShuSong-Z01)
- 英文:Garamond
- 整体淡灰色背景
- 红色强调色系统
- 衬线标题 + 等宽代码
适用场景: 商业案例、深度分析、知识分享
参数:
yaml
font_family_cn: 'FZShuSong-Z01','Songti SC',STSong,serif
font_family_en: 'Garamond',serif
font_size: 16
line_height: 1.9
accent_color: '#cf4436'
background_color: '#f7f6f1'
heading_font: 'Noto Serif SC','Songti SC',STSong,Georgia,serif
code_font: 'JetBrains Mono','SF Mono',Menlo,Consolas,monospaceFeatures:
- Chinese: FZShuSong-Z01
- English: Garamond
- Overall light gray background
- Red accent color system
- Serif headings + monospaced code
Applicable Scenarios: Business cases, in-depth analysis, knowledge sharing
Parameters:
yaml
font_family_cn: 'FZShuSong-Z01','Songti SC',STSong,serif
font_family_en: 'Garamond',serif
font_size: 16
line_height: 1.9
accent_color: '#cf4436'
background_color: '#f7f6f1'
heading_font: 'Noto Serif SC','Songti SC',STSong,Georgia,serif
code_font: 'JetBrains Mono','SF Mono',Menlo,Consolas,monospace4. modern(现代简约)
4. modern (Modern Minimalist)
特点:
- 无衬线字体
- 纯白背景
- 蓝色强调色
- 清晰现代
适用场景: 科技产品、教程、快讯
参数:
yaml
font_family_cn: 'PingFang SC','Hiragino Sans GB','Microsoft YaHei',sans-serif
font_family_en: 'SF Pro Display','Helvetica Neue',sans-serif
font_size: 16
line_height: 1.8
accent_color: '#007aff'
background_color: '#ffffff'
heading_font: 'PingFang SC','Hiragino Sans GB',sans-serif
code_font: 'SF Mono',Menlo,Consolas,monospaceFeatures:
- Sans-serif fonts
- Pure white background
- Blue accent color
- Clear and modern
Applicable Scenarios: Tech products, tutorials, news flashes
Parameters:
yaml
font_family_cn: 'PingFang SC','Hiragino Sans GB','Microsoft YaHei',sans-serif
font_family_en: 'SF Pro Display','Helvetica Neue',sans-serif
font_size: 16
line_height: 1.8
accent_color: '#007aff'
background_color: '#ffffff'
heading_font: 'PingFang SC','Hiragino Sans GB',sans-serif
code_font: 'SF Mono',Menlo,Consolas,monospace5. minimal(极简主义)
5. minimal (Minimalism)
特点:
- 极简黑白
- 大量留白
- 灰色调
- 克制优雅
适用场景: 哲学思考、个人随笔、艺术评论
参数:
yaml
font_family_cn: 'Noto Sans SC','PingFang SC',sans-serif
font_family_en: 'Inter','Helvetica Neue',sans-serif
font_size: 15
line_height: 2.0
accent_color: '#333333'
background_color: '#fafafa'
heading_font: 'Noto Sans SC',sans-serif
code_font: 'JetBrains Mono',monospaceFeatures:
- Minimalist black and white
- Large amounts of white space
- Gray tone
- Restrained and elegant
Applicable Scenarios: Philosophical thinking, personal essays, art reviews
Parameters:
yaml
font_family_cn: 'Noto Sans SC','PingFang SC',sans-serif
font_family_en: 'Inter','Helvetica Neue',sans-serif
font_size: 15
line_height: 2.0
accent_color: '#333333'
background_color: '#fafafa'
heading_font: 'Noto Sans SC',sans-serif
code_font: 'JetBrains Mono',monospaceRenderer Presets
Renderer Presets
主题不只换颜色。每个主题绑定一个 Markdown 渲染人格,负责标题、正文、引用、列表、代码、图片说明的结构、字号、行高、间距和字重。
| Preset | 绑定主题 | 版式语气 |
|---|---|---|
| | 纸感文档:正式、克制、标题左侧 ink-blue 竖线 |
| | 电子杂志家族:通过 |
| | 复古长文:居中标题、舒展行距、摘录式引用 |
| | 现代教程:无衬线层级、提示卡片、技术代码块 |
| | 极简笔记:低装饰、大留白、细线引用 |
公众号兼容硬规则: 所有 preset 输出均为 inline style;背景色使用 solid hex;外层 section、内容 section、文本 span 会重复声明 。
background-colorThemes are not just color changes. Each theme is bound to a Markdown rendering personality, responsible for the structure, font size, line height, spacing, and font weight of headings, body text, quotes, lists, code, and image captions.
| Preset | Bound Theme | Layout Tone |
|---|---|---|
| | Paper-style document: formal, restrained, ink-blue vertical line on the left of headings |
| | E-magazine family: presents five layouts of classic / research / fieldnote / archive / gallery respectively through |
| | Retro long-form article: centered headings, stretched line height, excerpt-style quotes |
| | Modern tutorial: sans-serif hierarchy, prompt cards, technical code blocks |
| | Minimalist notes: low decoration, large white space, thin-line quotes |
WeChat Official Account Compatibility Hard Rules: All preset outputs use inline styles; background colors use solid hex values; is declared repeatedly in outer sections, content sections, and text spans.
background-color主题参数说明
Theme Parameter Description
| 参数 | 说明 | 默认值 |
|---|---|---|
| 主题名称 | |
| 正文字号(px) | |
| 行高 | |
| 强调色(标题、链接) | |
| 背景色,必须使用 solid hex | |
| 内容最大宽度(px) | |
| 输出文件路径 | 自动生成 |
| Parameter | Description | Default Value |
|---|---|---|
| Theme Name | |
| Body Font Size (px) | |
| Line Height | |
| Accent Color (Headings, Links) | |
| Background Color, must use solid hex | |
| Maximum Content Width (px) | |
| Output File Path | Auto-generated |
输出规则
Output Rules
默认输出路径:
- 输入:
path/to/article.md - 输出:
path/to/article_wechat.html
输出内容:
- 完整的 HTML 文件
- 内联样式(可直接复制到公众号)
- 保留图片链接
- 自动处理代码块、引用块、列表等
Default Output Path:
- Input:
path/to/article.md - Output:
path/to/article_wechat.html
Output Content:
- Complete HTML file
- Inline styles (can be directly copied to official account)
- Retain image links
- Automatically process code blocks, quote blocks, lists, etc.
工作流程
Workflow
-
读取 Markdown 文件
- 解析 frontmatter(标题、摘要等)
- 提取正文内容
-
加载主题配置
- 读取主题参数
- 应用用户自定义参数
-
转换为 HTML
- Markdown → HTML 结构
- 应用主题样式(内联)
- 处理特殊元素(代码、图片、引用)
-
输出文件
- 生成完整 HTML
- 保存到指定路径
- 输出使用说明
-
Read Markdown File
- Parse frontmatter (title, summary, etc.)
- Extract body content
-
Load Theme Configuration
- Read theme parameters
- Apply user-defined parameters
-
Convert to HTML
- Markdown → HTML structure
- Apply theme styles (inline)
- Process special elements (code, images, quotes)
-
Output File
- Generate complete HTML
- Save to specified path
- Output usage instructions
主题预览
Theme Preview
不确定选哪个主题?使用主题预览生成器对比所有主题效果:
bash
undefinedNot sure which theme to choose? Use the theme preview generator to compare the effects of all themes:
bash
undefined生成所有主题的预览页面(使用默认示例文章)
Generate preview pages for all themes (use default sample article)
node scripts/generate-preview.mjs
node scripts/generate-preview.mjs
使用自定义文章生成预览
Generate preview with custom article
node scripts/generate-preview.mjs path/to/your-article.md
node scripts/generate-preview.mjs path/to/your-article.md
只预览指定主题(逗号分隔,无空格)
Preview only specified themes (comma-separated, no spaces)
node scripts/generate-preview.mjs article.md --themes magazine-ink,magazine-indigo,magazine-forest,magazine-kraft,magazine-dune
node scripts/generate-preview.mjs article.md --themes magazine-ink,magazine-indigo,magazine-forest,magazine-kraft,magazine-dune
自定义输出路径
Custom output path
node scripts/generate-preview.mjs article.md --themes kami,elegant --output /path/to/my-preview.html
预览页面会并排展示所选主题的效果,方便快速对比选择。生成的 `preview.html` 可以在浏览器中打开查看。node scripts/generate-preview.mjs article.md --themes kami,elegant --output /path/to/my-preview.html
The preview page will display the effects of the selected themes side by side, making it easy to compare and choose quickly. The generated `preview.html` can be opened in a browser to view.扩展新主题
Extend New Theme
步骤:
-
在目录创建新主题配置文件:
themes/yaml# themes/my-theme.yaml name: my-theme description: 我的自定义主题 font_family_cn: 'Custom Font CN' font_family_en: 'Custom Font EN' font_size: 16 line_height: 1.8 accent_color: '#ff6b6b' background_color: '#f8f9fa' heading_font: 'Heading Font' code_font: 'Code Font' -
使用新主题:bash
/wechat-styler article.md --theme my-theme
Steps:
-
Create a new theme configuration file in thedirectory:
themes/yaml# themes/my-theme.yaml name: my-theme description: My Custom Theme font_family_cn: 'Custom Font CN' font_family_en: 'Custom Font EN' font_size: 16 line_height: 1.8 accent_color: '#ff6b6b' background_color: '#f8f9fa' heading_font: 'Heading Font' code_font: 'Code Font' -
Use the new theme:bash
/wechat-styler article.md --theme my-theme
注意事项
Notes
- 字体回退:所有字体都有完整的回退栈,确保在不同系统上都能正常显示
- 图片处理:保留原始图片链接,确保图床可访问
- 代码块:使用等宽字体 + 浅色背景
- 引用块:浅底或细左线,避免厚重边框
- 图片居中:图片同时使用父级 和自身
text-align:center,防止公众号编辑器复制后图片偏移margin:0 auto - 公众号兼容:所有样式内联,背景色使用 solid hex,避免 rgba / body 背景在编辑器中丢失
- Font Fallback: All fonts have complete fallback stacks to ensure normal display on different systems
- Image Processing: Retain original image links, ensure image bed is accessible
- Code Blocks: Use monospaced fonts + light background
- Quote Blocks: Light background or thin left line, avoid heavy borders
- Image Centering: Images use both parent and their own
text-align:centerto prevent image offset after copying to the official account editormargin:0 auto - Official Account Compatibility: All styles are inline, background colors use solid hex values, avoid rgba / body background loss in the editor
示例
Example
输入 Markdown:
markdown
---
title: 文章标题
summary: 文章摘要
---Input Markdown:
markdown
---
title: Article Title
summary: Article Summary
---章节标题
Section Title
这是一段正文,包含加粗和。
代码
这是一段引用
**输出 HTML:**
- 完整的公众号可用 HTML
- 所有样式内联
- 可直接复制粘贴This is a paragraph of body text, including bold and .
code
This is a quote
**Output HTML:**
- Complete HTML usable for WeChat Official Accounts
- All styles are inline
- Can be directly copied and pasted技术实现
Technical Implementation
核心脚本:
scripts/convert.mjs依赖:
- Node.js 18+
- marked(Markdown 解析)
- js-yaml(YAML 解析)
目录结构:
wechat-styler/
├── SKILL.md
├── scripts/
│ └── convert.mjs
├── themes/
│ ├── elegant.yaml
│ ├── kami.yaml
│ ├── magazine-dune.yaml
│ ├── magazine-forest.yaml
│ ├── magazine-indigo.yaml
│ ├── magazine-ink.yaml
│ ├── magazine-kraft.yaml
│ ├── modern.yaml
│ └── minimal.yaml
└── templates/
└── base.html最后更新: 2026-04-24
版本: 1.3.0
作者: 大鹏
Core Script:
scripts/convert.mjsDependencies:
- Node.js 18+
- marked (Markdown parsing)
- js-yaml (YAML parsing)
Directory Structure:
wechat-styler/
├── SKILL.md
├── scripts/
│ └── convert.mjs
├── themes/
│ ├── elegant.yaml
│ ├── kami.yaml
│ ├── magazine-dune.yaml
│ ├── magazine-forest.yaml
│ ├── magazine-indigo.yaml
│ ├── magazine-ink.yaml
│ ├── magazine-kraft.yaml
│ ├── modern.yaml
│ └── minimal.yaml
└── templates/
└── base.htmlLast Updated: 2026-04-24
Version: 1.3.0
Author: Dapeng