npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@joaodotwork/md-2-pdf

v1.2.0

Published

Convert markdown files to PDF with mermaid diagram support

Readme

md-2-pdf

npm version License: MIT

A powerful CLI tool to convert Markdown files to PDF with built-in Mermaid diagram support. It bridges the gap between GitHub-flavored documentation and professional PDF exports.

Why md-2-pdf?

Most markdown-to-pdf converters struggle with diagrams or produce poorly formatted documents. md-2-pdf is designed to:

  • Preserve Vector Quality: Renders Mermaid diagrams as PDF vectors (not bitmaps) for lossless scaling.
  • Support GFM Conventions: Handles lists interrupting paragraphs, task lists, and other GitHub Flavored Markdown features.
  • Professional Typography: Uses xelatex by default for high-quality typesetting with smart page breaking.

Key Features

  • Mermaid Diagrams: Automatically detects ````mermaid` blocks and renders them as vector graphics.
  • Smart Formatting:
    • Standardized 11pt font and optimized line spacing.
    • Interactive, blue clickable links.
    • Automatic widow/orphan protection (keeps headers with content).
    • Customizable margins and geometry.
  • Multi-Engine Support: Automatically detects and uses the best available PDF engine (xelatex, pdflatex, weasyprint, or wkhtmltopdf).
  • Batch Processing: Convert single files or entire directories with one command.

Installation

Prerequisites

  1. Node.js & npm (Required for Mermaid rendering)
  2. Python 3 (Required for the core logic)
  3. Pandoc (The engine behind the conversion)
  4. PDF Engine (One of the following):
    • Recommended: xelatex (Install via MacTeX on macOS or texlive-full on Linux)
    • Alternative: weasyprint (pip install weasyprint)

Install via npm

npm install -g @joaodotwork/md-2-pdf

Or use pnpm / yarn:

pnpm add -g @joaodotwork/md-2-pdf

Usage

Single File Conversion

md-2-pdf manual.md

Creates manual.pdf in the same directory.

Batch Processing

Convert all markdown files in a directory:

md-2-pdf ./documentation

Advanced Options

# Specify a custom output name
md-2-pdf proposal.md -o Final_Proposal.pdf

# Check if all dependencies are correctly installed
md-2-pdf --check-only

Mermaid Support

Simply use standard Mermaid syntax in your markdown:

graph TD;
    A[Markdown File] -->|Processor| B(Extract Mermaid);
    B --> C{Render to PDF};
    C -->|Vector| D[High-Quality PDF];

The tool will extract these blocks, render them using mermaid-cli, and embed them back into the final document seamlessly.

Troubleshooting

If you encounter issues with PDF generation, ensure pandoc and a LaTeX engine (like xelatex) are in your PATH. You can verify this by running:

md-2-pdf --check-only

License

MIT © Joao Doria de Souza