A command-line tool to convert Markdown files containing Mermaid diagrams to PDF documents.
- Converts Markdown files to PDF
- Renders Mermaid diagrams as SVG images in the PDF
- Preserves all standard Markdown formatting
- Simple command-line interface
- Node.js (v14 or later)
- npm
- Clone the repository:
git clone https://github.com/klokie/mermaid-md-to-pdf.git
cd mermaid-md-to-pdf- Install dependencies:
npm install- Make the CLI available globally
npm linkmermaid-md-to-pdf <input-file> [options]-o, --output <output-file>: Output PDF file name (default:input-file.pdf)-h, --help: Show help
# Document with Mermaid Diagram
This is a sample document with a Mermaid diagram.
```mermaid
graph TD
A[Start] --> B{Is it working?}
B -->|Yes| C[Great!]
B -->|No| D[Debug]
D --> BThe diagram above shows a simple flowchart.
Running mermaid-md-to-pdf README.md will create README.pdf with the rendered Mermaid diagram. See README.pdf for the output.
- Parses the Markdown file to find Mermaid diagram code blocks
- Renders each Mermaid diagram to SVG using @mermaid-js/mermaid-cli
- Processes the Markdown content and embeds the SVG diagrams
- Converts the processed content to PDF using Puppeteer
You can customize the PDF styling by modifying the pdf-style.css file.
MIT