# Beautiful Mermaid > Renderiza diagramas Mermaid como SVG y PNG con la librería Beautiful Mermaid. Úsalo cuando el usuario pida renderizar un diagrama Mermaid. Fuente: https://skillsagentes.com/skills/calesthio/openmontage/beautiful-mermaid Markdown: https://skillsagentes.com/skills/calesthio/openmontage/beautiful-mermaid.md Repositorio: https://github.com/calesthio/OpenMontage Autor: calesthio Licencia: AGPL-3.0 Actualizado: hace 4 meses Coste de contexto: 32 tok instalada, 1.3k tok al activarse, 4.9k tok con todos los archivos del bundle Bundle: 4 archivos, 19 KB Permisos que pide: ninguno declarado ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add calesthio/OpenMontage --skill beautiful-mermaid --agent claude-code # Cursor npx -y skills add calesthio/OpenMontage --skill beautiful-mermaid --agent cursor # Codex npx -y skills add calesthio/OpenMontage --skill beautiful-mermaid --agent codex # Gemini CLI npx -y skills add calesthio/OpenMontage --skill beautiful-mermaid --agent gemini # Windsurf npx -y skills add calesthio/OpenMontage --skill beautiful-mermaid --agent windsurf # Cline npx -y skills add calesthio/OpenMontage --skill beautiful-mermaid --agent cline ``` ## Qué hace - Renderiza diagramas Mermaid a SVG con la librería Beautiful Mermaid - Envuelve el SVG en HTML y captura un PNG de alta resolución con agent-browser a 4K - Valida la sintaxis Mermaid antes de renderizar, con patrones para etiquetas de arista y caracteres especiales - Limpia los archivos intermedios al terminar - Trae guía de temas y diagnóstico para SVG vacíos o diagramas cortados ## Cuándo usarla - El usuario pide renderizar un diagrama Mermaid ## Qué la activa - "Renderiza este diagrama Mermaid" - "Conviérteme este flowchart en PNG" - "Hazme una imagen de este diagrama de secuencia" ## Antes de instalar - Necesita la librería Beautiful Mermaid y agent-browser para la captura del PNG en 4K. - Necesita en el PATH: bun, npx - Variables de entorno: THEMES - reads environment config ## Archivos - SKILL.md — 5 KB - references/mermaid-syntax.md — 4 KB - scripts/create-html.ts — 4 KB - scripts/render.ts — 6 KB ## SKILL.md Reproducido tal cual desde calesthio/OpenMontage bajo AGPL-3.0. Esta sección es el documento original y está en inglés. # Beautiful Mermaid Diagram Rendering Render Mermaid diagrams as SVG and PNG images using the Beautiful Mermaid library. ## Dependencies This skill requires the `agent-browser` skill for PNG rendering. Load it before proceeding with PNG capture. ## Supported Diagram Types - **Flowchart** - Process flows, decision trees, CI/CD pipelines - **Sequence** - API calls, OAuth flows, database transactions - **State** - State machines, connection lifecycles - **Class** - UML class diagrams, design patterns - **Entity-Relationship** - Database schemas, data models ## Available Themes Default, Dracula, Solarized, Zinc Dark, Tokyo Night, Tokyo Night Storm, Tokyo Night Light, Catppuccin Latte, Nord, Nord Light, GitHub Dark, GitHub Light, One Dark. If no theme is specified, use `default`. ## Common Syntax Patterns ### Flowchart Edge Labels Use pipe syntax for edge labels: ```mermaid A -->|label| B A ---|label| B ``` Avoid space-dash syntax which can cause incomplete renders: ```mermaid A -- label --> B # May cause issues ``` ### Node Labels with Special Characters Wrap labels containing special characters in quotes: ```mermaid A["Label with (parens)"] B["Label with / slash"] ``` ## Workflow ### Step 1: Generate or Validate Mermaid Code If the user provides a description rather than code, generate valid Mermaid syntax. Consult `references/mermaid-syntax.md` for full syntax details. ### Step 2: Render SVG Run the rendering script to produce an SVG file: ```bash bun run scripts/render.ts --code "graph TD; A-->B" --output diagram --theme default ``` Or from a file: ```bash bun run scripts/render.ts --input diagram.mmd --output diagram --theme tokyo-night ``` Alternative runtimes: ```bash npx tsx scripts/render.ts --code "..." --output diagram deno run --allow-read --allow-write --allow-net scripts/render.ts --code "..." --output diagram ``` This produces `.svg` in the current working directory. ### Step 3: Create HTML Wrapper Run the HTML wrapper script to prepare for screenshot: ```bash bun run scripts/create-html.ts --svg diagram.svg --output diagram.html ``` This creates a minimal HTML file that displays the SVG with proper padding and background. ### Step 4: Capture High-Resolution PNG with agent-browser Use the agent-browser CLI to capture a high-quality screenshot. Refer to the `agent-browser` skill for full CLI documentation. ```bash # Set 4K viewport for high-resolution capture agent-browser set viewport 3840 2160 # Open the HTML wrapper agent-browser open "file://$(pwd)/diagram.html" # Wait for render to complete agent-browser wait 1000 # Capture full-page screenshot agent-browser screenshot --full diagram.png # Close browser agent-browser close ``` For even higher resolution on complex diagrams, increase the viewport further or use the `--padding` option when creating the HTML wrapper to give the diagram more space. ### Step 5: Clean Up Intermediary Files After rendering, remove all intermediary files. Only the final `.svg` and `.png` should remain. Files to clean up: - The HTML wrapper file (e.g., `diagram.html`) - Any temporary `.mmd` files created to hold diagram code - Any other files created during the rendering process ```bash rm diagram.html ``` If a temporary `.mmd` file was created, remove it as well. ## Output Both outputs are always produced: - **SVG**: Vector format, infinitely scalable, small file size - **PNG**: High-resolution raster, captured at 4K (3840×2160) viewport with minimum 1200px diagram width Files are saved to the current working directory unless the user explicitly specifies a different path. ## Theme Selection Guide | Theme | Background | Best For | |-------|------------|----------| | default | Light grey | General use | | dracula | Dark purple | Dark mode preference | | tokyo-night | Dark blue | Modern dark aesthetic | | tokyo-night-storm | Darker blue | Higher contrast | | nord | Dark arctic | Muted, calm visuals | | nord-light | Light arctic | Light mode with soft tones | | github-dark | GitHub dark | Matches GitHub UI | | github-light | GitHub light | Matches GitHub UI | | catppuccin-latte | Warm light | Soft pastel aesthetic | | solarized | Tan/cream | Solarized colour scheme | | one-dark | Atom dark | Atom editor aesthetic | | zinc-dark | Neutral dark | Minimal, no colour bias | ## Troubleshooting ### Theme not applied Check the render script output for the `bg` and `fg` values, or inspect the SVG's opening tag for `--bg` and `--fg` CSS custom properties. ### Diagram appears cut off or incomplete - Check edge label syntax — use `-->|label|` pipe notation, not `-- label -->` - Verify all node IDs are unique - Check for unclosed brackets in node labels ### Render produces empty or malformed SVG - Validate Mermaid syntax at https://mermaid.live before rendering - Check for special characters that need escaping (wrap in quotes) - Ensure flowchart direction is specified (`graph TD`, `graph LR`, etc.) ## Dónde encaja - Categoría: [Documentos](https://skillsagentes.com/categorias/documentos.md) — Lee, escribe y transforma archivos PDF, DOCX, XLSX y PPTX. - Creador: [calesthio](https://skillsagentes.com/creators/calesthio.md) — 0 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [Seedance 2 5](https://skillsagentes.com/skills/calesthio/openmontage/seedance-2-5.md): Genera vídeo cinematográfico de 4-30 s con ByteDance Seedance 2.5 por fal.ai, Volcengine Ark, Runway o ComfyUI. Cubre el contrato de prompt 2.5, cortes duros, locks de continuidad y voz. - [Comfyui](https://skillsagentes.com/skills/calesthio/openmontage/comfyui.md): Úsalo al trabajar con workflows de ComfyUI en OpenMontage: comfyui_image/video/music, workflows propios, selección de output_node, modelos que faltan, LoRAs, poca VRAM e importación de workflows de la comunidad. - [Fish Audio Tts](https://skillsagentes.com/skills/calesthio/openmontage/fish-audio-tts.md): Genera narración expresiva y multilingüe con fish.audio (modelos S1 / S2) y reutiliza voces clonadas mediante reference_id. - [Minimax H3](https://skillsagentes.com/skills/calesthio/openmontage/minimax-h3.md): Genera vídeo con MiniMax H3 (Hailuo 3.0) por la API oficial v2, fal.ai, Runway, nodos partner de ComfyUI o pesos abiertos locales. Clips de 4-15s a 2K con animación de primer/último fotograma. - [Gemini Omni](https://skillsagentes.com/skills/calesthio/openmontage/gemini-omni.md): Genera y edita conversacionalmente vídeos cortos con Google Gemini Omni Flash: itera con ediciones en lenguaje natural, clips de 3-10s a 720p con audio y texto en pantalla, e imágenes de referencia por etiquetas. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)