mermaid-to-png
Mermaid to PNG
Extracts mermaid diagrams from markdown files, renders them to PNGs, and inserts image references after each mermaid block. The original mermaid code is preserved for future editing.
Usage
Run the script via bunx:
bunx ~/nixos-config/modules/programs/claude-code/skills/mermaid-to-png/mermaid-to-png.ts "<markdown-file>"
What it does
- Finds all
```mermaidcode blocks in the markdown file - Renders each to PNG via mermaid.ink API (no local browser needed)
- Saves PNGs to
assets/<filename-kebab-case>/diagram-N.png - Inserts
after each mermaid block - Preserves original mermaid code for future edits
Output structure
document.md
assets/
document/
diagram-1.png
diagram-2.png
...
Example
Before:
# My Doc
```mermaid
graph LR
A --> B
```
After:
# My Doc
```mermaid
graph LR
A --> B
```

Notes
- Uses mermaid.ink web API (requires internet)
- Filenames are converted to kebab-case (no spaces)
- White background for compatibility
- Idempotent: re-running will regenerate PNGs but not duplicate image refs (mermaid blocks without existing image refs get new ones)
More from michaelvessia/nixos-config
proxmox
|
15paperless
Search and manage documents in Paperless-ngx document management system. Use when the user asks about documents, invoices, receipts, tax forms, bills, or wants to search their document library.
13obsidian-save
|
12qmd
|
11home-assistant-manager
Expert-level Home Assistant configuration management with efficient deployment workflows (git and rapid scp iteration), remote CLI access via SSH and hass-cli, automation verification protocols, log analysis, reload vs restart optimization, and comprehensive Lovelace dashboard management for tablet-optimized UIs. Includes template patterns, card types, debugging strategies, and real-world examples.
11effect
Effect-TS best practices for services, errors, layers, schemas, and testing. Use when writing/reviewing Effect code, implementing services, handling errors, or composing layers.
10