md-mmd-pdf
v0.1.1
Published
CLI tool to convert Markdown with Mermaid diagrams to PDF.
Maintainers
Readme
md-mmd-pdf
md-mmd-pdf is a CLI that converts a Markdown file containing Mermaid diagrams into a PDF.
It uses Mermaid CLI in markdown mode to replace Mermaid fences with SVG artefacts, then uses md-to-pdf to render the final PDF.
Install
npm install -g md-mmd-pdfOr run it without global install:
npx md-mmd-pdf input.mdUsage
md-mmd-pdf <input.md> [options]Options
-o, --output <file.pdf>: output PDF path (default:<input-basename>.pdfin the input directory)--config <file>: md-to-pdf config file (.js,.cjs,.mjs,.json)--mermaid-config <file>: Mermaid config JSON formmdc -c--puppeteer-config <file>: Mermaid puppeteer config JSON formmdc -p--verbose: print command and subprocess output--keep-temp: keep transformed markdown and Mermaid artefacts-h, --help: show help-v, --version: show version
Examples
Convert a file using default output path:
md-mmd-pdf docs/architecture.mdWrite output to a custom location:
md-mmd-pdf docs/architecture.md --output output/architecture.pdfUse an md-to-pdf config file:
md-mmd-pdf docs/architecture.md --config md-to-pdf.config.jsKeep intermediate files for debugging:
md-mmd-pdf docs/architecture.md --keep-temp --verboseBehavior
- Single-file input and output only.
- Fails fast on Mermaid rendering errors.
- Returns non-zero exit code on any failure.
- Removes intermediate files/directories by default.
- Supports formal page-break markers:
- Canonical:
\newpage - Alias:
<!-- pagebreak -->
- Canonical:
- Page-break CSS is injected automatically (
break-after: page+ fallback).
Page Breaks
Use a standalone marker line:
\newpageor:
<!-- pagebreak -->Both are normalized to <div class="page-break"></div> before PDF generation.
md-to-pdf Config
--config loads an object and passes it into the md-to-pdf programmatic API.
basedir and dest are always set by md-mmd-pdf:
basedir= input markdown directorydest= resolved output PDF path
This guarantees stable relative asset resolution and deterministic output destination.
Troubleshooting
Mermaid render failure
If Mermaid parsing fails, rerun with --verbose to see the underlying mmdc error.
Browser launch issues (CI/Linux)
Mermaid CLI and md-to-pdf use Puppeteer. In constrained environments you may need Puppeteer launch settings in your Mermaid or md-to-pdf config files.
Contributing
Maintainer/development/release notes live in CONTRIBUTING.md.
License
MIT
