wechat-styler

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

WeChat 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
undefined
bash
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',monospace
Features:
  • 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',monospace

2. magazine 系列(电子杂志 × 电子墨水)

2. magazine Series (E-Magazine × E-Ink)

magazine-web-ppt
迁移来的 5 套预设,保留
ink / paper / tint
的杂志色彩关系,同时改造成微信公众号安全 HTML:不使用
rgba()
,所有背景色均为 solid hex。
主题命令变体字体 / 版式人格
墨水经典
--theme magazine-ink
ink-classic
无衬线正文 + 衬线标题,细 rule、dash list、pull quote,通用杂志内页
靛蓝瓷
--theme magazine-indigo
indigo-research
Inter/SF Pro 正文 + Source Serif 标题,左侧研究栏、note quote、技术代码块
森林墨
--theme magazine-forest
forest-fieldnote
楷体/宋体正文 + 非虚构标题,居中标题、field note 引用、自然图片说明
牛皮纸
--theme magazine-kraft
kraft-archive
宋体正文 + archive 标题盒,档案式引用、罗马数字有序列表、旧纸代码框
沙丘
--theme magazine-dune
dune-gallery
Avenir 正文 + Didot/Bodoni 标题,右对齐画廊标题、gallery quote、极简图片说明
共同特点:
  • 每个主题都有独立字体栈、字号、行距、段距、标题结构、列表 marker、引用块、代码块和图片说明。
  • 分隔以留白、短淡线和局部标识为主;不会在每个章节之间自动插入整宽实线。
  • 五个主题共享
    magazine-editorial
    renderer 入口,但通过
    magazine_variant
    走不同结构分支,不只是替换颜色。
  • 所有背景色都使用 solid hex,并在区块与文本 span 上重复声明
    background-color
    ,降低复制到公众号编辑器后背景色丢失的概率。
  • 图片自身带
    margin:0 auto
    居中兜底,避免公众号编辑器复制后改写图片宽度导致图片靠左。
  • 版式保留杂志感,但输出仍完全内联,可直接复制到公众号编辑器。
5 presets migrated from
magazine-web-ppt
, retaining the magazine color relationship of
ink / paper / tint
, while transformed into WeChat Official Account-safe HTML: no
rgba()
is used, all background colors are solid hex values.
ThemeCommandVariantFont / Layout Personality
Ink Classic
--theme magazine-ink
ink-classic
Sans-serif body text + serif headings, thin rules, dash lists, pull quotes, universal magazine inner pages
Indigo Porcelain
--theme magazine-indigo
indigo-research
Inter/SF Pro body text + Source Serif headings, left research bar, note quotes, technical code blocks
Forest Ink
--theme magazine-forest
forest-fieldnote
Regular script/Songti body text + non-fiction headings, centered headings, field note quotes, natural image captions
Kraft Paper
--theme magazine-kraft
kraft-archive
Songti body text + archive title boxes, archive-style quotes, Roman numeral ordered lists, old paper code boxes
Dune
--theme magazine-dune
dune-gallery
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
    magazine-editorial
    renderer entry, but follow different structural branches through
    magazine_variant
    , not just color replacement.
  • All background colors use solid hex values, and
    background-color
    is declared repeatedly on blocks and text spans to reduce the probability of background color loss after copying to the official account editor.
  • Images have
    margin:0 auto
    centered fallback to avoid left alignment caused by the official account editor rewriting image width after copying.
  • 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,monospace
Features:
  • 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,monospace

4. 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,monospace
Features:
  • 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,monospace

5. 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',monospace
Features:
  • 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',monospace

Renderer Presets

Renderer Presets

主题不只换颜色。每个主题绑定一个 Markdown 渲染人格,负责标题、正文、引用、列表、代码、图片说明的结构、字号、行高、间距和字重。
Preset绑定主题版式语气
kami-document
kami
纸感文档:正式、克制、标题左侧 ink-blue 竖线
magazine-editorial
magazine-ink
/
magazine-indigo
/
magazine-forest
/
magazine-kraft
/
magazine-dune
电子杂志家族:通过
magazine_variant
分别呈现 classic / research / fieldnote / archive / gallery 五种版式
elegant-essay
elegant
复古长文:居中标题、舒展行距、摘录式引用
modern-technical
modern
现代教程:无衬线层级、提示卡片、技术代码块
minimal-notes
minimal
极简笔记:低装饰、大留白、细线引用
公众号兼容硬规则: 所有 preset 输出均为 inline style;背景色使用 solid hex;外层 section、内容 section、文本 span 会重复声明
background-color
Themes 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.
PresetBound ThemeLayout Tone
kami-document
kami
Paper-style document: formal, restrained, ink-blue vertical line on the left of headings
magazine-editorial
magazine-ink
/
magazine-indigo
/
magazine-forest
/
magazine-kraft
/
magazine-dune
E-magazine family: presents five layouts of classic / research / fieldnote / archive / gallery respectively through
magazine_variant
elegant-essay
elegant
Retro long-form article: centered headings, stretched line height, excerpt-style quotes
modern-technical
modern
Modern tutorial: sans-serif hierarchy, prompt cards, technical code blocks
minimal-notes
minimal
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;
background-color
is declared repeatedly in outer sections, content sections, and text spans.

主题参数说明

Theme Parameter Description

参数说明默认值
--theme
主题名称
kami
--font-size
正文字号(px)
16
--line-height
行高
1.55
--accent-color
强调色(标题、链接)
#1B365D
--background-color
背景色,必须使用 solid hex
#f5f4ed
--max-width
内容最大宽度(px)
640
--output
输出文件路径自动生成
ParameterDescriptionDefault Value
--theme
Theme Name
kami
--font-size
Body Font Size (px)
16
--line-height
Line Height
1.55
--accent-color
Accent Color (Headings, Links)
#1B365D
--background-color
Background Color, must use solid hex
#f5f4ed
--max-width
Maximum Content Width (px)
640
--output
Output File PathAuto-generated

输出规则

Output Rules

默认输出路径:
  • 输入:
    path/to/article.md
  • 输出:
    path/to/article_wechat.html
输出内容:
  1. 完整的 HTML 文件
  2. 内联样式(可直接复制到公众号)
  3. 保留图片链接
  4. 自动处理代码块、引用块、列表等
Default Output Path:
  • Input:
    path/to/article.md
  • Output:
    path/to/article_wechat.html
Output Content:
  1. Complete HTML file
  2. Inline styles (can be directly copied to official account)
  3. Retain image links
  4. Automatically process code blocks, quote blocks, lists, etc.

工作流程

Workflow

  1. 读取 Markdown 文件
    • 解析 frontmatter(标题、摘要等)
    • 提取正文内容
  2. 加载主题配置
    • 读取主题参数
    • 应用用户自定义参数
  3. 转换为 HTML
    • Markdown → HTML 结构
    • 应用主题样式(内联)
    • 处理特殊元素(代码、图片、引用)
  4. 输出文件
    • 生成完整 HTML
    • 保存到指定路径
    • 输出使用说明
  1. Read Markdown File
    • Parse frontmatter (title, summary, etc.)
    • Extract body content
  2. Load Theme Configuration
    • Read theme parameters
    • Apply user-defined parameters
  3. Convert to HTML
    • Markdown → HTML structure
    • Apply theme styles (inline)
    • Process special elements (code, images, quotes)
  4. Output File
    • Generate complete HTML
    • Save to specified path
    • Output usage instructions

主题预览

Theme Preview

不确定选哪个主题?使用主题预览生成器对比所有主题效果:
bash
undefined
Not 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

步骤:
  1. 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'
  2. 使用新主题:
    bash
    /wechat-styler article.md --theme my-theme
Steps:
  1. Create a new theme configuration file in the
    themes/
    directory:
    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'
  2. Use the new theme:
    bash
    /wechat-styler article.md --theme my-theme

注意事项

Notes

  1. 字体回退:所有字体都有完整的回退栈,确保在不同系统上都能正常显示
  2. 图片处理:保留原始图片链接,确保图床可访问
  3. 代码块:使用等宽字体 + 浅色背景
  4. 引用块:浅底或细左线,避免厚重边框
  5. 图片居中:图片同时使用父级
    text-align:center
    和自身
    margin:0 auto
    ,防止公众号编辑器复制后图片偏移
  6. 公众号兼容:所有样式内联,背景色使用 solid hex,避免 rgba / body 背景在编辑器中丢失
  1. Font Fallback: All fonts have complete fallback stacks to ensure normal display on different systems
  2. Image Processing: Retain original image links, ensure image bed is accessible
  3. Code Blocks: Use monospaced fonts + light background
  4. Quote Blocks: Light background or thin left line, avoid heavy borders
  5. Image Centering: Images use both parent
    text-align:center
    and their own
    margin:0 auto
    to prevent image offset after copying to the official account editor
  6. 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
.
Image Description
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.mjs
Dependencies:
  • 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.html

Last Updated: 2026-04-24 Version: 1.3.0 Author: Dapeng