← 返回
沟通协作

Baoyu Markdown To Html

Converts Markdown to styled HTML with WeChat-compatible themes. Supports code highlighting, math, PlantUML, footnotes, alerts, infographics, and optional bot...
将 Markdown 转换为微信兼容的样式化 HTML,支持代码高亮、数学公式、PlantUML、脚注、提示框、信息图以及可选机器人...
jimliu
沟通协作 clawhub v1.117.2 4 版本 99578.2 Key: 无需
★ 2
Stars
📥 3,265
下载
💾 341
安装
4
版本
#latest

概述

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):

  1. Prefer built-in user-input tools exposed by the current agent runtime — e.g., AskUserQuestion, request_user_input, clarify, ask_user, or any equivalent.
  2. 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.
  3. 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.

ScriptPurpose
-----------------
scripts/main.tsMain entry point

Preferences (EXTEND.md)

Check EXTEND.md in priority order — the first one found wins:

PriorityPathScope
-----------------------
1.baoyu-skills/baoyu-markdown-to-html/EXTEND.mdProject
2${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-markdown-to-html/EXTEND.mdXDG
3$HOME/.baoyu-skills/baoyu-markdown-to-html/EXTEND.mdUser home

If none 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:

  1. Read input markdown file
  2. Check if content contains CJK characters (Chinese/Japanese/Korean)
  3. 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):

  1. User explicitly specified theme (CLI --theme or conversation)
  2. EXTEND.md default_theme (this skill's own EXTEND.md, checked in Step 0)
  3. baoyu-post-to-wechat EXTEND.md default_theme (cross-skill fallback)
  4. 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:

OptionDescriptionDefault
------------------------------
--theme Theme name (default, grace, simple, modern)default
`--color hex>`Primary color: preset name or hex valuetheme default
--font-family Font: sans, serif, serif-cjk, mono, or CSS valuetheme default
--font-size Font size: 14px, 15px, 16px, 17px, 18px16px
--title </code></td><td>Override title from frontmatter</td><td></td></tr><tr><td><code>--cite</code></td><td>Convert external links to bottom citations, append <code>引用链接</code> section</td><td>false (off)</td></tr><tr><td><code>--keep-title</code></td><td>Keep the first heading in content</td><td>false (removed)</td></tr><tr><td><code>--help</code></td><td>Show help</td><td></td></tr></tbody></table><p><strong>Color Presets:</strong></p><table><thead><tr><th>Name</th><th>Hex</th><th>Label</th></tr></thead><tbody><tr><td>------</td><td>-----</td><td>-------</td></tr><tr><td>blue</td><td>#0F4C81</td><td>Classic Blue</td></tr><tr><td>green</td><td>#009874</td><td>Emerald Green</td></tr><tr><td>vermilion</td><td>#FA5151</td><td>Vibrant Vermilion</td></tr><tr><td>yellow</td><td>#FECE00</td><td>Lemon Yellow</td></tr><tr><td>purple</td><td>#92617E</td><td>Lavender Purple</td></tr><tr><td>sky</td><td>#55C9EA</td><td>Sky Blue</td></tr><tr><td>rose</td><td>#B76E79</td><td>Rose Gold</td></tr><tr><td>olive</td><td>#556B2F</td><td>Olive Green</td></tr><tr><td>black</td><td>#333333</td><td>Graphite Black</td></tr><tr><td>gray</td><td>#A9A9A9</td><td>Smoke Gray</td></tr><tr><td>pink</td><td>#FFB7C5</td><td>Sakura Pink</td></tr><tr><td>red</td><td>#A93226</td><td>China Red</td></tr><tr><td>orange</td><td>#D97757</td><td>Warm Orange (modern default)</td></tr></tbody></table><p><strong>Examples:</strong></p><pre><code># 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" </code></pre><h2>Output</h2><p><strong>File location</strong>: Same directory as input markdown file.</p><ul><li>Input: <code>/path/to/article.md</code></li><li>Output: <code>/path/to/article.html</code></li></ul><p><strong>Conflict handling</strong>: If HTML file already exists, it will be backed up first:</p><ul><li>Backup: <code>/path/to/article.html.bak-YYYYMMDDHHMMSS</code></li></ul><p><strong>JSON output to stdout:</strong></p><pre><code>{ "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" } ] } </code></pre><h2>Themes</h2><table><thead><tr><th>Theme</th><th>Description</th></tr></thead><tbody><tr><td>-------</td><td>-------------</td></tr><tr><td><code>default</code></td><td>Classic - traditional layout, centered title with bottom border, H2 with white text on colored background</td></tr><tr><td><code>grace</code></td><td>Elegant - text shadow, rounded cards, refined blockquotes (by @brzhang)</td></tr><tr><td><code>simple</code></td><td>Minimal - modern minimalist, asymmetric rounded corners, clean whitespace (by @okooo5km)</td></tr><tr><td><code>modern</code></td><td>Modern - large radius, pill-shaped titles, relaxed line height (pair with <code>--color red</code> for traditional red-gold style)</td></tr></tbody></table><h2>Supported Markdown Features</h2><table><thead><tr><th>Feature</th><th>Syntax</th></tr></thead><tbody><tr><td>---------</td><td>--------</td></tr><tr><td>Headings</td><td><code># H1</code> to <code>###### H6</code></td></tr><tr><td>Bold/Italic</td><td><code><strong>bold</strong></code>, <code><em>italic</em></code></td></tr><tr><td>Code blocks</td><td><code> </code>`<code>lang </code> with syntax highlighting</td></tr><tr><td>Inline code</td><td>`<code> </code>code<code> </code>`</td></tr><tr><td>Tables</td><td>GitHub-flavored markdown tables</td></tr><tr><td>Images</td><td><code>!<a href="src" target="_blank" rel="noopener">alt</a></code></td></tr><tr><td>Links</td><td><code><a href="url" target="_blank" rel="noopener">text</a></code>; add <code>--cite</code> to move ordinary external links into bottom references</td></tr><tr><td>Blockquotes</td><td><code>> quote</code></td></tr><tr><td>Lists</td><td><code>-</code> unordered, <code>1.</code> ordered</td></tr><tr><td>Alerts</td><td><code>> [!NOTE]</code>, <code>> [!WARNING]</code>, etc.</td></tr><tr><td>Footnotes</td><td><code>[^1]</code> references</td></tr><tr><td>Ruby text</td><td>`{base</td><td>annotation}`</td></tr><tr><td>Mermaid</td><td><code> </code>`<code>mermaid </code> diagrams</td></tr><tr><td>PlantUML</td><td><code> </code>`<code>plantuml </code> diagrams</td></tr></tbody></table><h2>Frontmatter</h2><p>Supports YAML frontmatter for metadata:</p><pre><code>--- title: Article Title author: Author Name description: Article summary --- </code></pre><p>If no title is found, extracts from first H1/H2 heading or uses filename.</p><h2>Extension Support</h2><p>Custom configurations via EXTEND.md. See <strong>Preferences</strong> section for paths and supported options.</p></div> </div> </div> <div id="tab-versions" class="detail-content"> <div class="detail-section"> <h2>版本历史</h2> <p style="margin-bottom:12px;font-size:14px;color:#94a3b8;">共 4 个版本</p> <ul class="version-list"> <li> <div> <span class="version-tag">v1.117.2</span> <span style="font-size:11px;color:#5b6abf;margin-left:8px;background:#eef0ff;padding:1px 8px;border-radius:10px;">当前</span> </div> <div style="font-size:12px;color:#94a3b8;"> 2026-05-19 10:19 安全 安全 </div> </li> <li> <div> <span class="version-tag">v1.103.2</span> </div> <div style="font-size:12px;color:#94a3b8;"> 2026-04-30 10:20 安全 安全 </div> </li> <li> <div> <span class="version-tag">v1.76.2</span> </div> <div style="font-size:12px;color:#94a3b8;"> 2026-03-29 02:43 安全 </div> </li> <li> <div> <span class="version-tag">v1.60.0</span> </div> <div style="font-size:12px;color:#94a3b8;"> 2026-03-18 19:12 </div> </li> </ul> </div> </div> <div id="tab-security" class="detail-content"> <div class="detail-section"> <h2>安全检测</h2> <div class="sec-grid"> <div class="sec-card"> <h4>腾讯云安全 (Keen)</h4> <div class="sec-status sec-safe"> 安全,无风险 </div> <a href="https://tix.qq.com/search/skill?keyword=ff32199637865de03176893c29ad585c" target="_blank">查看报告</a> </div> <div class="sec-card"> <h4>腾讯云安全 (Sanbu)</h4> <div class="sec-status sec-safe"> 安全,无风险 </div> <a href="https://static.cloudsec.tencent.com/html-report-v2/2026/05/25/409965_bd6de689d0c1b7c8ebbadce1c9154e6d.html?q-sign-algorithm=sha1&q-ak=AKID8JMG1bzBC1dz96qNhssfFftujT1NCoFi&q-sign-time=1781218851%3B1812754851&q-key-time=1781218851%3B1812754851&q-header-list=host&q-url-param-list=&q-signature=15879d2c2c11fb5f0f79451907542379defa26e0" target="_blank">查看报告</a> </div> </div> </div> </div> <!-- Recommended Skills --> <div style="margin-top:24px;"> <h2 style="font-size:18px;font-weight:600;margin-bottom:16px;">🔗 相关推荐</h2> <div class="rec-grid"> <div class="rec-card"> <span class="badge-cat" style="margin-bottom:8px;display:inline-block;">data-analysis</span> <h3><a href="/s/baoyu-infographic">Baoyu Infographic</a></h3> <div class="rec-owner">jimliu</div> <div class="rec-desc">生成21种布局和22种视觉风格的专业信息图,分析内容,推荐布局×风格组合,并生成出版物。</div> <div class="rec-stats"> <span style="color:#f39c12;">★ 9</span> <span style="color:#5b6abf;">📥 9,249</span> </div> </div> <div class="rec-card"> <span class="badge-cat" style="margin-bottom:8px;display:inline-block;">communication-collaboration</span> <h3><a href="/s/himalaya">Himalaya</a></h3> <div class="rec-owner">lamelas</div> <div class="rec-desc">{"answer":"通过IMAP/SMTP管理邮件的CLI。可在终端使用 `himalaya` 收发、回复、转发、搜索及整理邮件。支持多账户与MML(MIME元语言)编写邮件。"}</div> <div class="rec-stats"> <span style="color:#f39c12;">★ 68</span> <span style="color:#5b6abf;">📥 45,581</span> </div> </div> <div class="rec-card"> <span class="badge-cat" style="margin-bottom:8px;display:inline-block;">communication-collaboration</span> <h3><a href="/s/slack">Slack</a></h3> <div class="rec-owner">steipete</div> <div class="rec-desc">当需要通过 slack 工具从 Clawdbot 控制 Slack 时使用,包括在频道或私信中回复消息或置顶/取消置顶项目。</div> <div class="rec-stats"> <span style="color:#f39c12;">★ 157</span> <span style="color:#5b6abf;">📥 47,674</span> </div> </div> </div> </div> </div> <script> document.addEventListener('DOMContentLoaded',function(){ document.querySelectorAll('.detail-tab').forEach(function(btn){ btn.addEventListener('click',function(e){ var tab = this.getAttribute('data-tab'); document.querySelectorAll('.detail-tab').forEach(function(b){b.classList.remove('active')}); document.querySelectorAll('.detail-content').forEach(function(c){c.classList.remove('active')}); this.classList.add('active'); var el = document.getElementById('tab-'+tab); if(el) el.classList.add('active'); }); }); }); </script> <div class="footer"> <p>Skill工具集 © 2026</p> </div></body> </html>