Claim types: EXPENSES, MEAL, MILEAGE, OT. Export excludes local MongoDB data and claim file upload blobs. Co-authored-by: Cursor <cursoragent@cursor.com>
Mermaid SVG Generation
Automatically generates SVG files from Mermaid (.mmd) diagram files. Scans all directories and generates/updates SVG files as needed.
Setup
Prerequisites
-
Install mermaid-cli:
brew install mermaid-cliOr via npm:
npm install -g @mermaid-js/mermaid-cli -
Install Chrome (one of the following):
Option 1: System Chrome (Recommended)
brew install --cask google-chromeOption 2: Puppeteer Chrome
npx puppeteer browsers install chrome-headless-shellThe script automatically detects and uses either installation method.
-
Install VS Code Extension (for auto-generation):
Install the Run on Save extension by nburnet1.
In VS Code:
- Press
Cmd+Shift+X(Mac) orCtrl+Shift+X(Windows/Linux) - Search for "Run on Save"
- Install the extension by nburnet1
- Press
Usage
Manual:
python3 scripts/mermaid/generate-svgs.py
Automatic (VS Code):
Configure VS Code to run the script automatically when you save .mmd files (see VS Code Configuration below).
VS Code Configuration
1. Extensions Configuration
Add this to your .vscode/extensions.json:
{
"recommendations": [
"emeraldwalk.RunOnSave",
"bierner.markdown-mermaid"
]
}
2. Settings Configuration
Add this to your .vscode/settings.json:
{
"files.associations": {
"*.mmd": "mermaid"
},
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.mmd$",
"cmd": "python3 ${workspaceFolder}/scripts/mermaid/generate-svgs.py",
"message": "Generating SVG from Mermaid...",
"messageAfter": "SVG generated successfully!",
"showElapsed": true,
"isAsync": true
}
]
}
}
Important: The configuration key must be "emeraldwalk.runonsave" (not "runonsave"). This is the correct key for the Run on Save extension.
Required Extensions:
- Run on Save extension by nburnet1 (emeraldwalk.RunOnSave)
- Markdown Mermaid by bierner (bierner.markdown-mermaid) - for Mermaid syntax highlighting
How It Works
- Scans all directories recursively for
.mmdfiles - Generates corresponding
.svgfiles next to each.mmdfile - Only generates/updates SVGs when:
- SVG file doesn't exist, or
.mmdfile is newer than the.svgfile
- Automatically detects Chrome installation (system or puppeteer)
Context
This script is used in the project to automatically generate SVG images from Mermaid diagram source files. The SVG files are then referenced in markdown documentation for display on GitHub and other markdown viewers.
When you edit a .mmd file and save it, the corresponding .svg file is automatically regenerated, keeping your diagrams up-to-date.