markmap-export-cli
v0.1.0
Published
CLI tool to convert Markdown to mindmap SVG using markmap-lib
Downloads
108
Maintainers
Readme
markmap-export-cli
CLI tool to convert Markdown to interactive mindmap SVG using markmap-lib.
Installation
Global Installation
npm install -g markmap-export-cliUsing npx (No Installation)
npx markmap-export-cli --input "# Hello\n\n## World"Usage
Basic Usage
# Direct markdown input
markmap-export-cli --input "# Hello\n\n## World\n\n- Item 1\n- Item 2"
# From file
markmap-export-cli --input input.md --output output.svg
# With custom dimensions
markmap-export-cli --input input.md --width 1600 --height 1200Command Line Options
| Option | Description | Default |
|--------|-------------|---------|
| -i, --input <input> | Markdown content or .md file path (required) | - |
| -o, --output <output> | Output SVG file path | output.svg |
| -W, --width <width> | Output width in pixels | 1200 |
| -H, --height <height> | Output height in pixels | Auto |
| -t, --theme <theme> | Theme (default or dark) | default |
Programmatic Usage
const { exportToSvg } = require('markmap-export-cli');
async function main() {
const result = await exportToSvg({
input: '# Hello\n\n## World',
output: 'mindmap.svg',
width: 1200,
height: 800
});
if (result.success) {
console.log('Exported to:', result.filePath);
} else {
console.error('Error:', result.error);
}
}
main();Installing Chrome
markmap-export-cli requires a Chrome/Chromium browser to render the mindmap. You have two options:
Option 1: Let Puppeteer Download Chrome (Default)
By default, Puppeteer will automatically download a compatible version of Chromium during installation. No manual action required.
Option 2: Install Chrome/Chromium Manually
If you prefer to use your own Chrome installation (e.g., to save disk space or for faster installs), follow these steps:
Install Google Chrome
macOS:
# Using Homebrew
brew install --cask google-chrome
# Or download from: https://www.google.com/chrome/Windows:
# Using winget
winget install Google.Chrome
# Using Chocolatey
choco install googlechrome
# Or download from: https://www.google.com/chrome/Linux (Ubuntu/Debian):
# Download and install Google Chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
# Or install Chromium (open-source version)
sudo apt install chromium-browserLinux (Fedora/CentOS/RHEL):
# Install Chromium
sudo dnf install chromium
# Or for Google Chrome
sudo dnf install fedora-workstation-repositories
sudo dnf config-manager --set-enabled google-chrome
sudo dnf install google-chrome-stableAlternative: Install Chromium
Chromium is the open-source version of Chrome and works equally well:
- macOS:
brew install --cask chromium - Windows: Download from https://www.chromium.org/getting-involved/download-chromium
- Linux: Available in most package managers as
chromiumorchromium-browser
After installing Chrome/Chromium, see Using System Chrome below for configuration.
Using System Chrome (Skip Puppeteer Download)
If you don't want Puppeteer to download Chrome (e.g., slow network or disk space concerns), you can use your existing Chrome/Chromium browser:
1. Skip Chrome Download During Install
# Skip automatic Chrome download
PUPPETEER_SKIP_DOWNLOAD=true npm install -g markmap-export-cli2. Configure Chrome Path
Set the PUPPETEER_EXECUTABLE_PATH environment variable to your Chrome executable:
macOS:
# Google Chrome (stable)
export PUPPETEER_EXECUTABLE_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
# Google Chrome Canary
export PUPPETEER_EXECUTABLE_PATH="/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary"
# Microsoft Edge
export PUPPETEER_EXECUTABLE_PATH="/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"Windows:
REM Google Chrome
set PUPPETEER_EXECUTABLE_PATH="C:\Program Files\Google\Chrome\Application\chrome.exe"
REM Microsoft Edge
set PUPPETEER_EXECUTABLE_PATH="C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"Linux:
# Google Chrome
export PUPPETEER_EXECUTABLE_PATH="/usr/bin/google-chrome"
# Chromium
export PUPPETEER_EXECUTABLE_PATH="/usr/bin/chromium"
# Microsoft Edge
export PUPPETEER_EXECUTABLE_PATH="/usr/bin/microsoft-edge"3. Use the CLI
markmap-export-cli --input "# Hello\n\n## World"Environment Variables
| Variable | Description |
|----------|-------------|
| PUPPETEER_EXECUTABLE_PATH | Path to custom Chrome/Chromium executable |
| PUPPETEER_SKIP_DOWNLOAD | Set to true to skip Chrome download during install |
| MARKMAP_OFFLINE | Set to true to use offline mode (embedded assets) |
Requirements
- Node.js >= 16
- Chrome/Chromium browser (auto-downloaded by Puppeteer, or use system Chrome)
How It Works
- Parse Markdown content using
markmap-lib - Generate HTML with embedded mindmap visualization
- Use Puppeteer to render the HTML and extract SVG
- Save the SVG file to the specified output path
License
MIT
