前端转换
- 作者仓库星标 21,713
- 叉子 2,492
- 作者更新于 2026年6月13日 05:00
- 作者仓库 baoyu-skills
- 领域
- 文档
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 92 / 100 · 已通过审计
- 作者 / 版本 / 许可
- @JimLiu · v1.117.3 · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- macOS · Linux · Windows
- 底层运行要求
- Bun
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 网络行为
- 仅限本地
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: baoyu-markdown-to-html
description: Converts Markdown to styled HTML with WeChat-compatible themes. Supports code highlighting, math…
category: 文档
runtime: Bun
---
# baoyu-markdown-to-html 输出预览
## PART A: 任务判断
- 适用问题:PRD、RFC、README、项目说明或知识库整理。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“User Input Tools / Script Directory / Preferences (EXTEND.md)”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于PRD、RFC、README、项目说明或知识库整理,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“User Input Tools / Script Directory / Preferences (EXTEND.md)”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、主要在本地完成、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文出现了 `/path` 这类斜杠命令;如果你的 Agent 支持命令触发,优先用命令开场,再补充目标和边界。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令。
先用一个小任务确认它会围绕“User Input Tools / Script Directory / Preferences (EXTEND.md)”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: baoyu-markdown-to-html
description: Converts Markdown to styled HTML with WeChat-compatible themes. Supports code highlighting, math…
category: 文档
source: JimLiu/baoyu-skills
---
# baoyu-markdown-to-html
## 什么时候使用
- 把 Markdown 文章转成可发布的 HTML——代码高亮、图片宽度、引用样式都正确处理 适合处理README、PRD、RFC、教程和知识库文档,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任…
- 面向PRD、RFC、README、项目说明或知识库整理,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「User Input Tools / Script Directory / Preferences (EXTEND.md)」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "baoyu-markdown-to-html" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> User Input Tools / Script Directory / Preferences (EXTEND.md)
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> Bun | 读取文件、写入/修改文件、执行终端命令 | 主要在本地完成
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Markdown 转 HTML 转换器
将 Markdown 文件转换为精美风格的 HTML,内联 CSS,针对微信公众号及其他平台优化。
用户输入工具
当此技能提示用户时,请遵循以下工具选择规则(优先级顺序):
- 优先使用当前 Agent 运行时暴露的内置用户输入工具——例如
AskUserQuestion、request_user_input、clarify、ask_user或任何等效工具。 - 备选方案:如果不存在此类工具,则发出带编号的纯文本消息,并要求用户回复所选编号/答案以回答每个问题。
- 批量处理:如果工具支持每次调用处理多个问题,则将所有适用问题合并到一次调用中;如果只支持单个问题,则按优先级顺序逐一提问。
下面具体的 AskUserQuestion 引用是示例——在其他运行时请替换为本地等效工具。
脚本目录
Agent 执行:将此 SKILL.md 目录确定为 {baseDir}。解析 ${BUN_X} 运行时:如果安装了 bun → bun;如果 npx 可用 → npx -y bun;否则建议安装 bun。将 {baseDir} 和 ${BUN_X} 替换为实际值。
| 脚本 | 用途 |
|---|---|
scripts/main.ts |
主入口点 |
首选项 (EXTEND.md)
按优先级顺序检查 EXTEND.md——找到的第一个生效:
| 优先级 | 路径 | 范围 |
|---|---|---|
| 1 | .baoyu-skills/baoyu-markdown-to-html/EXTEND.md |
项目 |
| 2 | ${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-markdown-to-html/EXTEND.md |
XDG |
| 3 | $HOME/.baoyu-skills/baoyu-markdown-to-html/EXTEND.md |
用户主目录 |
如果未找到,则使用默认值。
EXTEND.md 支持:默认主题、自定义 CSS 变量、代码块样式。
工作流程
步骤 0:预检查(中文内容)
条件:仅当输入文件包含中文文本时才执行。
检测:
- 读取输入 Markdown 文件
- 检查内容是否包含 CJK 字符(中文/日文/韩文)
- 如果没有 CJK 内容 → 跳到步骤 1
格式化建议:
如果检测到 CJK 内容且 baoyu-format-markdown 技能可用:
使用 AskUserQuestion 询问是否先进行格式化。格式化可以修复:
- 粗体标记内包含标点符号导致
**解析失败的问题 - CJK/英文间距问题
如果用户同意:调用 baoyu-format-markdown 技能格式化文件,然后使用格式化后的文件作为输入。
如果用户拒绝:继续使用原始文件。
步骤 1:确定主题
主题解析顺序(第一个匹配项胜出):
- 用户明确指定的主题(CLI
--theme或对话中) - EXTEND.md
default_theme(此技能自己的 EXTEND.md,在步骤 0 中检查) baoyu-post-to-wechatEXTEND.mddefault_theme(跨技能回退)- 如果未找到 → 使用 AskUserQuestion 确认
跨技能 EXTEND.md 检查(仅当此技能的 EXTEND.md 没有 default_theme 时):
如果 $HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md 存在,则读取它并查找 default_theme: 行。如果存在该值则使用;否则继续。
如果主题从 EXTEND.md 解析:直接使用,不要询问用户。
如果未找到默认主题:使用 AskUserQuestion 从下面的主题表格中确认一个主题。
步骤 1.5:确定引用模式
默认:关闭。默认不询问。
仅当用户明确要求“微信外链转底部引用”、“底部引用”、“文末引用”或传递 --cite 时启用。
启用时的行为:
- 普通外部链接以带编号的上标形式呈现,并收集在最终的「引用链接」部分下。
https://mp.weixin.qq.com/...链接保持为直接链接,不移至底部。- 链接文本等于 URL 的裸链接保持内联。
步骤 2:转换
${BUN_X} {baseDir}/scripts/main.ts <markdown_file> --theme <theme> [--cite]
步骤 3:报告结果
显示 JSON 结果中的输出路径。如果创建了备份,请提及。
用法
${BUN_X} {baseDir}/scripts/main.ts <markdown_file> [options]
选项:
| 选项 | 描述 | 默认值 |
|---|---|---|
--theme <name> |
主题名称 (default, grace, simple, modern) | default |
--color <name|hex> |
主色调:预设名称或十六进制值 | 主题默认值 |
--font-family <name> |
字体:sans, serif, serif-cjk, mono, 或 CSS 值 | 主题默认值 |
--font-size <N> |
字体大小:14px, 15px, 16px, 17px, 18px | 16px |
--title <title> |
覆盖 frontmatter 中的标题 | |
--cite |
将外部链接转换为底部引用,并附加「引用链接」部分 | false (关闭) |
--keep-title |
保留内容中的第一个标题 | false (移除) |
--help |
显示帮助 |
颜色预设:
| 名称 | 十六进制 | 标签 |
|---|---|---|
| blue | #0F4C81 | 经典蓝 |
| green | #009874 | 翡翠绿 |
| vermilion | #FA5151 | 活力朱红 |
| yellow | #FECE00 | 柠檬黄 |
| purple | #92617E | 淡紫色 |
| sky | #55C9EA | 天空蓝 |
| rose | #B76E79 | 玫瑰金 |
| olive | #556B2F | 橄榄绿 |
| black | #333333 | 石墨黑 |
| gray | #A9A9A9 | 烟灰色 |
| pink | #FFB7C5 | 樱花粉 |
| red | #A93226 | 中国红 |
| orange | #D97757 | 暖橙 (modern 默认) |
示例:
# 基本转换(使用默认主题,移除第一个标题)
${BUN_X} {baseDir}/scripts/main.ts article.md
# 使用特定主题
${BUN_X} {baseDir}/scripts/main.ts article.md --theme grace
# 带自定义颜色的主题
${BUN_X} {baseDir}/scripts/main.ts article.md --theme modern --color red
# 启用普通外部链接的底部引用
${BUN_X} {baseDir}/scripts/main.ts article.md --cite
# 保留内容中的第一个标题
${BUN_X} {baseDir}/scripts/main.ts article.md --keep-title
# 覆盖标题
${BUN_X} {baseDir}/scripts/main.ts article.md --title "My Article"
输出
文件位置:与输入 Markdown 文件在同一目录。
- 输入:
/path/to/article.md - 输出:
/path/to/article.html
冲突处理:如果 HTML 文件已存在,将首先进行备份:
- 备份:
/path/to/article.html.bak-YYYYMMDDHHMMSS
JSON 输出到标准输出:
{
"title": "Article Title",
"author": "Author Name",
"summary": "Article summary...",
"htmlPath": "/path/to/article.html",
"backupPath": "/path/to/article.html.bak-20260128180000",
"contentImages": [
{
"placeholder": "MDTOHTMLIMGPH_1",
"localPath": "/path/to/img.png",
"originalPath": "imgs/image.png"
}
]
}
主题
| 主题 | 描述 |
|---|---|
default |
经典 - 传统布局,居中标题带底边框,H2 带白色文字在彩色背景上 |
grace |
优雅 - 文本阴影,圆角卡片,精致的引用块(由 @brzhang 提供) |
simple |
极简 - 现代极简主义,不对称圆角,干净的留白(由 @okooo5km 提供) |
modern |
现代 - 大圆角,药丸形标题,宽松行高(搭配 --color red 可获得传统红金风格) |
支持的 Markdown 功能
| 功能 | 语法 |
|---|---|
| 标题 | # H1 到 ###### H6 |
| 粗体/斜体 | **bold**, *italic* |
| 代码块 | ```lang 带语法高亮 |
| 行内代码 | `code` |
| 表格 | GitHub 风格的 Markdown 表格 |
| 图片 |  |
| 链接 | [text](url);添加 --cite 将普通外部链接移至底部引用 |
| 引用块 | > quote |
| 列表 | - 无序,1. 有序 |
| 提示 | > [!NOTE], > [!WARNING], 等 |
| 脚注 | [^1] 引用 |
| Ruby 文本 | `{base |
| Mermaid | ```mermaid 图表 |
| PlantUML | ```plantuml 图表 |
Frontmatter
支持 YAML frontmatter 用于元数据:
---
title: Article Title
author: Author Name
description: Article summary
---
如果未找到标题,则从第一个 H1/H2 标题中提取或使用文件名。
扩展支持
通过 EXTEND.md 进行自定义配置。请参阅首选项部分了解路径和支持的选项。
Markdown to HTML Converter
Converts Markdown files to beautifully styled HTML with inline CSS, optimized for WeChat Official Account and other platforms.
User Input Tools
When this skill prompts the user, follow this tool-selection rule (priority order):
- Prefer built-in user-input tools exposed by the current agent runtime — e.g.,
AskUserQuestion,request_user_input,clarify,ask_user, or any equivalent. - Fallback: if no such tool exists, emit a numbered plain-text message and ask the user to reply with the chosen number/answer for each question.
- Batching: if the tool supports multiple questions per call, combine all applicable questions into a single call; if only single-question, ask them one at a time in priority order.
Concrete AskUserQuestion references below are examples — substitute the local equivalent in other runtimes.
Script Directory
Agent Execution: Determine this SKILL.md directory as {baseDir}. Resolve ${BUN_X} runtime: if bun installed → bun; if npx available → npx -y bun; else suggest installing bun. Replace {baseDir} and ${BUN_X} with actual values.
| Script | Purpose |
|---|---|
scripts/main.ts |
Main entry point |
Preferences (EXTEND.md)
Check EXTEND.md in priority order — the first one found wins:
| Priority | Path | Scope |
|---|---|---|
| 1 | .baoyu-skills/baoyu-markdown-to-html/EXTEND.md |
Project |
| 2 | ${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-markdown-to-html/EXTEND.md |
XDG |
| 3 | $HOME/.baoyu-skills/baoyu-markdown-to-html/EXTEND.md |
User home |
If none found, use defaults.
EXTEND.md supports: default theme, custom CSS variables, code block style, mermaid defaults (mermaid_theme, mermaid_scale, mermaid_background).
Workflow
Step 0: Pre-check (Chinese Content)
Condition: Only execute if input file contains Chinese text.
Detection:
- Read input markdown file
- Check if content contains CJK characters (Chinese/Japanese/Korean)
- If no CJK content → skip to Step 1
Format Suggestion:
If CJK content detected AND baoyu-format-markdown skill is available:
Use AskUserQuestion to ask whether to format first. Formatting can fix:
- Bold markers with punctuation inside causing
**parse failures - CJK/English spacing issues
If user agrees: Invoke baoyu-format-markdown skill to format the file, then use formatted file as input.
If user declines: Continue with original file.
Step 1: Determine Theme
Theme resolution order (first match wins):
- User explicitly specified theme (CLI
--themeor conversation) - EXTEND.md
default_theme(this skill's own EXTEND.md, checked in Step 0) baoyu-post-to-wechatEXTEND.mddefault_theme(cross-skill fallback)- If none found → use AskUserQuestion to confirm
Cross-skill EXTEND.md check (only if this skill's EXTEND.md has no default_theme):
Read $HOME/.baoyu-skills/baoyu-post-to-wechat/EXTEND.md if it exists and look for a default_theme: line. Use the value if present; otherwise fall through.
If theme is resolved from EXTEND.md: Use it directly, do NOT ask the user.
If no default found: use AskUserQuestion to confirm a theme from the Themes table below.
Step 1.5: Determine Citation Mode
Default: Off. Do not ask by default.
Enable only if the user explicitly asks for "微信外链转底部引用", "底部引用", "文末引用", or passes --cite.
Behavior when enabled:
- Ordinary external links are rendered with numbered superscripts and collected under a final
引用链接section. https://mp.weixin.qq.com/...links stay as direct links and are not moved to the bottom.- Bare links where link text equals URL stay inline.
Step 2: Convert
${BUN_X} {baseDir}/scripts/main.ts <markdown_file> --theme <theme> [--cite]
Step 3: Report Result
Display the output path from JSON result. If backup was created, mention it.
Usage
${BUN_X} {baseDir}/scripts/main.ts <markdown_file> [options]
Options:
| Option | Description | Default |
|---|---|---|
--theme <name> |
Theme name (default, grace, simple, modern) | default |
--color <name|hex> |
Primary color: preset name or hex value | theme default |
--font-family <name> |
Font: sans, serif, serif-cjk, mono, or CSS value | theme default |
--font-size <N> |
Font size: 14px, 15px, 16px, 17px, 18px | 16px |
--title <title> |
Override title from frontmatter | |
--cite |
Convert external links to bottom citations, append 引用链接 section |
false (off) |
--keep-title |
Keep the first heading in content | false (removed) |
--mermaid-theme <name> |
Mermaid theme: default, forest, dark, neutral, base |
default |
--mermaid-scale <N> |
Mermaid render scale (positive number ≤ 4) | 2 |
--mermaid-width <N> |
Mermaid target display width in CSS px; PNG is rendered at width × scale pixels when the diagram is narrower than this |
860 |
--mermaid-bg <value> |
Mermaid background: white, transparent, or #hex |
white |
--no-mermaid |
Skip Mermaid PNG rendering; emit <pre class="mermaid"> fallback |
false |
--help |
Show help |
Color Presets:
| Name | Hex | Label |
|---|---|---|
| blue | #0F4C81 | Classic Blue |
| green | #009874 | Emerald Green |
| vermilion | #FA5151 | Vibrant Vermilion |
| yellow | #FECE00 | Lemon Yellow |
| purple | #92617E | Lavender Purple |
| sky | #55C9EA | Sky Blue |
| rose | #B76E79 | Rose Gold |
| olive | #556B2F | Olive Green |
| black | #333333 | Graphite Black |
| gray | #A9A9A9 | Smoke Gray |
| pink | #FFB7C5 | Sakura Pink |
| red | #A93226 | China Red |
| orange | #D97757 | Warm Orange (modern default) |
Examples:
# Basic conversion (uses default theme, removes first heading)
${BUN_X} {baseDir}/scripts/main.ts article.md
# With specific theme
${BUN_X} {baseDir}/scripts/main.ts article.md --theme grace
# Theme with custom color
${BUN_X} {baseDir}/scripts/main.ts article.md --theme modern --color red
# Enable bottom citations for ordinary external links
${BUN_X} {baseDir}/scripts/main.ts article.md --cite
# Keep the first heading in content
${BUN_X} {baseDir}/scripts/main.ts article.md --keep-title
# Override title
${BUN_X} {baseDir}/scripts/main.ts article.md --title "My Article"
Output
File location: Same directory as input markdown file.
- Input:
/path/to/article.md - Output:
/path/to/article.html
Conflict handling: If HTML file already exists, it will be backed up first:
- Backup:
/path/to/article.html.bak-YYYYMMDDHHMMSS
JSON output to stdout:
{
"title": "Article Title",
"author": "Author Name",
"summary": "Article summary...",
"htmlPath": "/path/to/article.html",
"backupPath": "/path/to/article.html.bak-20260128180000",
"contentImages": [
{
"placeholder": "MDTOHTMLIMGPH_1",
"localPath": "/path/to/img.png",
"originalPath": "imgs/image.png"
}
],
"mermaidImages": [
{
"hash": "a1b2c3d4e5f6",
"localPath": "/path/to/imgs/.mermaid-cache/mermaid-a1b2c3d4e5f6.png",
"cached": false
}
]
}
Mermaid rendering: Code blocks fenced as ```mermaid are rendered to PNGs via headless Chrome (CDP) and cached at imgs/.mermaid-cache/mermaid-<hash>.png. The cache key includes the code, theme, scale, target width, background, and mermaid version. Add imgs/.mermaid-cache/ to .gitignore if you do not want generated diagrams checked in. Requires Chrome/Chromium/Edge on the system; otherwise the block falls back to <pre class="mermaid">…</pre> and conversion still succeeds.
Themes
| Theme | Description |
|---|---|
default |
Classic - traditional layout, centered title with bottom border, H2 with white text on colored background |
grace |
Elegant - text shadow, rounded cards, refined blockquotes (by @brzhang) |
simple |
Minimal - modern minimalist, asymmetric rounded corners, clean whitespace (by @okooo5km) |
modern |
Modern - large radius, pill-shaped titles, relaxed line height (pair with --color red for traditional red-gold style) |
Supported Markdown Features
| Feature | Syntax |
|---|---|
| Headings | # H1 to ###### H6 |
| Bold/Italic | **bold**, *italic* |
| Code blocks | ```lang with syntax highlighting |
| Inline code | `code` |
| Tables | GitHub-flavored markdown tables |
| Images |  |
| Links | [text](url); add --cite to move ordinary external links into bottom references |
| Blockquotes | > quote |
| Lists | - unordered, 1. ordered |
| Alerts | > [!NOTE], > [!WARNING], etc. |
| Footnotes | [^1] references |
| Ruby text | `{base |
| Mermaid | ```mermaid blocks rendered to local PNG via headless Chrome (cached under imgs/.mermaid-cache/); falls back to <pre class="mermaid"> if Chrome is unavailable or rendering fails |
| PlantUML | ```plantuml diagrams |
Frontmatter
Supports YAML frontmatter for metadata:
---
title: Article Title
author: Author Name
description: Article summary
---
If no title is found, extracts from first H1/H2 heading or uses filename.
Extension Support
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核