$ show mermaid-js/mermaid-cli
mermaid-cli is a command-line interface for generating diagrams from Mermaid syntax. It processes input files (.mmd, .md, .markdown) containing Mermaid diagram definitions and outputs SVG, PNG, or PDF files. The architecture centers around a Puppeteer-driven rendering pipeline that launches a headless browser to render Mermaid diagrams via the Mermaid library. Key features include Markdown diagram extraction, configurable theming, CSS injection, icon pack support, and programmable Node.js API. The CLI entry point is src/cli.js, which delegates to the run() and renderMermaid() functions in src/index.js for core functionality. External dependencies include Puppeteer, Mermaid, and various layout engines (ELK, tidy-tree).
The LLM identified 2 files worth highlighting for reuse:
Provides request interception to serve local files as HTTP resources in Puppeteer, enabling ES module loading without a local server. Demonstrates non-obvious skill in solving a common Puppeteer limitation through URL rewriting and file serving.
Exports run() and renderMermaid() functions for programmatic Mermaid diagram rendering. Handles Markdown code block extraction, browser setup, dependency loading via interceptor, and output format conversion. Represents a clean separation of concerns between CLI and library concerns.