重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
mermaid-to-image by zc277584121/marketing-skills
npx skills add https://github.com/zc277584121/marketing-skills --skill mermaid-to-image将 Markdown(或其他文本)文件中的 ````mermaid` 代码块转换为 PNG 图片,并用图片引用替换代码块。适用于不支持原生渲染 Mermaid 的平台(如 GitHub Pages/Jekyll、Dev.to 等)。
用户可能指定:
convert mermaid blocks in docs/architecture.mdconvert mermaid in all files under docs/convert the second mermaid block in README.md扫描目标文件以查找 ````mermaid` 代码块。在继续之前,报告找到了多少个代码块以及位于哪些文件中。
检查项目结构以找到通常存储图片的位置:
# 查找常见的图片目录
ls -d images/ img/ assets/ assets/images/ static/images/ docs/images/ 2>/dev/null
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
如果存在明确的图片目录(例如 images/、assets/images/),则使用它。如果合适,可以按主题创建子目录(例如 images/<topic>/)。
如果没有明显的图片目录或存在多个候选目录,则询问用户:
我应该将渲染的 Mermaid 图片保存在哪里?
1. images/ (新建)
2. assets/images/
3. docs/figures/
4. 自定义 — 输入路径
提示:添加 "remember" 可将此选择保存到 CLAUDE.local.md。
如果用户说 "remember",则将选择保存到项目的 CLAUDE.local.md:
## Mermaid 图片输出
- **图片目录**: `<chosen-path>`
在后续运行时,检查 CLAUDE.local.md 中是否存在 ## Mermaid 图片输出 部分,并直接使用它。
使用 mermaid.ink API 来渲染图表。为每个代码块运行此 Python 代码片段:
import base64, urllib.request
def render_mermaid(code: str, output_path: str):
"""通过 mermaid.ink API 将 Mermaid 图表渲染为 PNG。"""
encoded = base64.urlsafe_b64encode(code.encode()).decode()
url = f"https://mermaid.ink/img/{encoded}?bgColor=white"
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
resp = urllib.request.urlopen(req, timeout=30)
with open(output_path, "wb") as f:
f.write(resp.read())
重要: User-Agent 请求头是必需的 — 没有它,mermaid.ink 会返回 403 错误。
基于图表内容使用描述性的文件名,而非通用名称:
architecture-overview.png、data-flow.png、heartbeat-sequence.pngmermaid-1.png、diagram.png、image1.png使用从文件到图片的相对路径,将每个 mermaid ... 代码块替换为 Markdown 图片引用:

如果项目使用绝对 URL(例如 GitHub Pages),则使用它们:

选择与项目现有图片引用风格匹配的链接样式。如果不确定,请使用相对路径。
处理完成后,总结:
.rst、.txt)。每周安装次数
95
仓库
首次出现
9 天前
安全审计
安装于
trae-cn95
codebuddy95
github-copilot95
codex95
kimi-cli95
gemini-cli95
Convert ````mermaid` code blocks in Markdown (or other text) files into PNG images, and replace the code blocks with image references. Useful for platforms that don't render Mermaid natively (GitHub Pages/Jekyll, Dev.to, etc.).
The user may specify:
convert mermaid blocks in docs/architecture.mdconvert mermaid in all files under docs/convert the second mermaid block in README.mdScan the target file(s) for ````mermaid` code blocks. Report how many blocks were found and in which files before proceeding.
Check the project structure to find where images are typically stored:
# Look for common image directories
ls -d images/ img/ assets/ assets/images/ static/images/ docs/images/ 2>/dev/null
If a clear image directory exists (e.g., images/, assets/images/), use it. Create a subdirectory by topic if appropriate (e.g., images/<topic>/).
If no image directory is obvious or multiple candidates exist , ask the user:
Where should I save the rendered Mermaid images?
1. images/ (create new)
2. assets/images/
3. docs/figures/
4. Custom — enter a path
Tip: add "remember" to save this choice to CLAUDE.local.md.
If the user says "remember", save the choice to the project's CLAUDE.local.md:
## Mermaid Image Output
- **Image directory**: `<chosen-path>`
On subsequent runs, check CLAUDE.local.md for a ## Mermaid Image Output section and use it directly.
Use the mermaid.ink API to render diagrams. Run this Python snippet for each block:
import base64, urllib.request
def render_mermaid(code: str, output_path: str):
"""Render a Mermaid diagram to PNG via mermaid.ink API."""
encoded = base64.urlsafe_b64encode(code.encode()).decode()
url = f"https://mermaid.ink/img/{encoded}?bgColor=white"
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
resp = urllib.request.urlopen(req, timeout=30)
with open(output_path, "wb") as f:
f.write(resp.read())
Important: The User-Agent header is required — mermaid.ink returns 403 without it.
Use descriptive filenames based on the diagram content, not generic names:
architecture-overview.png, data-flow.png, heartbeat-sequence.pngmermaid-1.png, diagram.png, image1.pngReplace each mermaid ... block with a Markdown image reference using a relative path from the file to the image:

If the project uses absolute URLs (e.g., GitHub Pages), use those instead:

Choose the link style that matches the project's existing image references. If unsure, use relative paths.
After processing, summarize:
.rst, .txt).Weekly Installs
95
Repository
First Seen
9 days ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
trae-cn95
codebuddy95
github-copilot95
codex95
kimi-cli95
gemini-cli95
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
48,700 周安装