mermaid-render

Renders Mermaid code fences in Markdown files to PNG images using Mermaid CLI.

5|1|Updated Jul 31, 2026
One-click install
npx skills add https://github.com/shiker1996/wechat-editroom --skill mermaid-render-shiker1996
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mermaid-render
Source: https://github.com/shiker1996/wechat-editroom/tree/main/skills/mermaid-render
Command: npx skills add https://github.com/shiker1996/wechat-editroom --skill mermaid-render-shiker1996

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @mermaid-js/mermaid-cli, puppeteer, and includes scripts (resource) components.

What problem does it solve? Markdown documents containing Mermaid diagram fences cannot be published directly to platforms like WeChat that require static images. This Skill converts each explicit mermaid fence into a rendered PNG and rewrites the Markdown to reference the local image path, so diagrams survive the publishing pipeline. ## Core Features & Use Cases - **Deterministic fence rendering**: Extracts every mermaid fence in order, writes .mmd sources, and renders PNGs via the locally installed @mermaid-js/mermaid-cli with Puppeteer-driven Chrome. - Safe failure handling: A failed fence keeps its original Mermaid source in the output and is reported in a JSON summary, so no content is ever silently deleted. - Theme-aware output: Applies project theme tokens (colors, background) to the Mermaid config so diagrams match the article's visual style. - Use Case: While typesetting a WeChat article, run the pipeline on images.md to turn all flowcharts, sequence diagrams, and state diagrams into 1080px-wide PNGs referenced by relative paths, ready for optional authorized upload. ## Quick Start Ask the agent to render all Mermaid fences in your Markdown file into PNG images by running the render-mermaid script with your input and output file paths.

Frequently Asked Questions about mermaid-render

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I convert Mermaid diagrams in Markdown to PNG images?

Run the render-mermaid.mjs script with your input Markdown path, output path, and optional image directory. It extracts every ```mermaid fence, renders each one to a PNG with Mermaid CLI, and rewrites the Markdown to reference the generated images.

What tool renders Mermaid diagrams to images from the command line?

The @mermaid-js/mermaid-cli package (mmdc) renders Mermaid source files to PNG using a headless Chrome browser via Puppeteer. This Skill invokes the locally installed mmdc directly with Node to avoid Windows spawn issues with .cmd shims.

Does Mermaid CLI work without a system Chrome installation?

Yes, if Puppeteer has a managed browser in its cache, the script resolves it automatically. You can also set PUPPETEER_EXECUTABLE_PATH to point at any Chrome executable; otherwise it falls back to standard system Chrome install locations.

Why does Mermaid rendering fail with a browser launch timeout?

Chrome occasionally fails to launch under concurrent processes, producing WS endpoint timeout errors. The script automatically retries the render once for these launch failures before marking the fence as failed and preserving its original source.

What happens to Mermaid fences that fail to render?

Failed fences are left untouched in the output Markdown and listed in the JSON report's failed array with an error message. The script exits with code 1 when any fence fails, and no content is ever deleted.