| name | mage-md-to-html |
| description | Converts Markdown to styled HTML with WeChat-compatible themes. Supports code highlighting, math, PlantUML, footnotes, alerts, and infographics. Use when user asks for "markdown to html", "convert md to html", "md่ฝฌhtml", or needs styled HTML output from markdown. |
Markdown to HTML Converter
Converts Markdown files to beautifully styled HTML with inline CSS, optimized for WeChat Official Account and other platforms.
Script Directory
Agent Execution: Determine this SKILL.md directory as SKILL_DIR, then use ${SKILL_DIR}/scripts/<name>.ts.
| Script | Purpose |
|---|
scripts/main.ts | Main entry point |
Preferences (EXTEND.md)
Use Bash to check EXTEND.md existence (priority order):
test -f .mage-skills/mage-md-to-html/EXTEND.md && echo "project"
test -f "$HOME/.mage-skills/mage-md-to-html/EXTEND.md" && echo "user"
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโ
โ Path โ Location โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโค
โ .mage-skills/mage-md-to-html/EXTEND.md โ Project directory โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโค
โ $HOME/.mage-skills/mage-md-to-html/EXTEND.md โ User home โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Result โ Action โ
โโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Found โ Read, parse, apply settings โ
โโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Not found โ Use defaults โ
โโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
EXTEND.md Supports: Default theme | Custom CSS variables | Code block style
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 mage-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 mage-format-markdown skill to format the file, then use formatted file as input.
If user declines: Continue with original file.
Step 1: Confirm Theme
Before converting, use AskUserQuestion to confirm the theme (unless user already specified):
| Theme | Description |
|---|
default (Recommended) | ็ปๅ
ธไธป้ข - ไผ ็ปๆ็๏ผๆ ้ขๅฑ
ไธญๅธฆๅบ่พน๏ผไบ็บงๆ ้ข็ฝๅญๅฝฉๅบ |
grace | ไผ้
ไธป้ข - ๆๅญ้ดๅฝฑ๏ผๅ่งๅก็๏ผ็ฒพ่ดๅผ็จๅ |
simple | ็ฎๆดไธป้ข - ็ฐไปฃๆ็ฎ้ฃ๏ผไธๅฏน็งฐๅ่ง๏ผๆธ
็ฝ็็ฝ |
Step 2: Convert
npx -y bun ${SKILL_DIR}/scripts/main.ts <markdown_file> --theme <theme>
Step 3: Report Result
Display the output path from JSON result. If backup was created, mention it.
Usage
npx -y bun ${SKILL_DIR}/scripts/main.ts <markdown_file> [options]
Options:
| Option | Description | Default |
|---|
--theme <name> | Theme name (default, grace, simple) | default |
--title <title> | Override title from frontmatter | |
--keep-title | Keep the first heading in content | false (removed) |
--help | Show help | |
Examples:
npx -y bun ${SKILL_DIR}/scripts/main.ts article.md
npx -y bun ${SKILL_DIR}/scripts/main.ts article.md --theme grace
npx -y bun ${SKILL_DIR}/scripts/main.ts article.md --keep-title
npx -y bun ${SKILL_DIR}/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"
}
]
}
Themes
| Theme | Description |
|---|
default | ็ปๅ
ธไธป้ข - ไผ ็ปๆ็๏ผๆ ้ขๅฑ
ไธญๅธฆๅบ่พน๏ผไบ็บงๆ ้ข็ฝๅญๅฝฉๅบ |
grace | ไผ้
ไธป้ข - ๆๅญ้ดๅฝฑ๏ผๅ่งๅก็๏ผ็ฒพ่ดๅผ็จๅ (by @brzhang) |
simple | ็ฎๆดไธป้ข - ็ฐไปฃๆ็ฎ้ฃ๏ผไธๅฏน็งฐๅ่ง๏ผๆธ
็ฝ็็ฝ (by @okooo5km) |
ๆ ทๅผๆไปถไธไพ่ต๏ผๅ
ฌไผๅทๅ
ผๅฎน๏ผ
ๆ ทๅผๆไปถ๏ผscripts/md/themes/๏ผ๏ผ
| ๆไปถ | ไฝ็จ |
|---|
base.css | ๅบ็ก๏ผๅฎนๅจๅญไฝใๅญๅทใ่ก้ซใ#output ไธ blockquote ็ reset๏ผไพ่ต CSS ๅ้ --md-font-familyใ--md-font-size |
default.css | ็ปๅ
ธไธป้ข๏ผh1/h2 ๅฑ
ไธญไธๅบ่พน/ๅฝฉๅบใh3 ๅทฆ่พนๆกใๆฎต่ฝ/ๅผ็จ/ไปฃ็ /่กจๆ ผ/alert ็ญๅฎๆดๆ็ |
grace.css | ไผ้
ไธป้ข๏ผ้ดๅฝฑใๅ่งใๅผ็จๅๆ ทๅผ |
simple.css | ็ฎๆดไธป้ข๏ผๆ็ฎใไธๅฏน็งฐๅ่งใ็็ฝ |
CSS ๅ้๏ผ็ฑ render ๅ
่ๆถๆฟๆขไธบ้ป่ฎคๅผ๏ผ๏ผ--md-primary-color๏ผ้ป่ฎค #0F4C81๏ผใ--md-font-familyใ--md-font-size๏ผ้ป่ฎค 16px๏ผใ--blockquote-background๏ผ้ป่ฎค #f7f7f7๏ผใ--foregroundใ
่พๅบ๏ผไฝฟ็จ juice ๅฐไธ่ฟฐ CSS ๅ
่ๅฐ HTML๏ผไพฟไบๅพฎไฟกๅ
ฌไผๅท็ญ็ฏๅขๆญฃ็กฎๆพ็คบ๏ผไธไพ่ตๅค้จๆ ทๅผ่กจ๏ผใ
npm ไพ่ต๏ผ้ๅจ scripts/md ไธๆง่ก npm install๏ผ๏ผ
| ไพ่ต | ็จ้ |
|---|
front-matter | ่งฃๆ YAML frontmatter |
marked | Markdown โ HTML |
highlight.js | ไปฃ็ ้ซไบฎ |
juice | ๆ ทๅผๅ
่๏ผๅ
ฌไผๅทๅ
ผๅฎนๅ
ณ้ฎ๏ผ |
reading-time | ้
่ฏปๆถ้ด |
unified / remark-parse / remark-stringify / remark-cjk-friendly | CJK ๅ ็ฒ็ญ้ขๅค็ |
fflate | ้จๅๆฉๅฑ๏ผๅฆ PlantUML๏ผๅฏ่ฝ็จๅฐ |
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) with footnote references |
| Blockquotes | > quote |
| Lists | - unordered, 1. ordered |
| Alerts | > [!NOTE], > [!WARNING], etc. |
| Footnotes | [^1] references |
| Ruby text | `{base |
| Mermaid | ```mermaid diagrams |
| PlantUML | ```plantuml diagrams |
Frontmatter
Supports YAML frontmatter for metadata:
---
title: Article Title
author: Author Name
description: Article summary
---
่ฅ frontmatter ๆ title๏ผmain ไผไปๆญฃๆ็ฌฌไธไธช #/## ๆ ้ขๆๅๅนถๅๅ
ฅไผ ็ป render ็ไธดๆถๆไปถ frontmatter๏ผไฟ่ฏๆ็ป HTML ็ <title> ๆญฃ็กฎ๏ผๅฆๅ render ไผ้ๅไธบไธดๆถๆไปถๅ๏ผๅฆ temp-article๏ผใ
Extension Support
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.