Skip to main content

Convert Markdown files with Mermaid diagrams to PDF

Project description

MermaidMD2PDF

A powerful command-line tool that converts Markdown documents containing Mermaid diagrams into beautifully formatted PDFs.

Features

  • Convert Markdown files with Mermaid diagrams to PDF
  • Support for multiple Mermaid diagram types
  • High-quality PDF output with embedded diagrams
  • Command-line interface for easy integration
  • Comprehensive error handling and validation

Prerequisites

  • Python 3.8 or higher
  • Pandoc (for PDF generation)
  • Mermaid CLI (for diagram rendering)

Installing Prerequisites

macOS

# Install Pandoc
brew install pandoc

# Install Mermaid CLI
npm install -g @mermaid-js/mermaid-cli

Linux

# Install Pandoc
sudo apt-get install pandoc

# Install Mermaid CLI
npm install -g @mermaid-js/mermaid-cli

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/MermaidMD2PDF.git
cd MermaidMD2PDF
  1. Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate  # On Linux/macOS
# or
.venv\Scripts\activate  # On Windows
  1. Install the package:
pip install -e .

Usage

Basic usage:

mermaidmd2pdf input.md output.pdf

Command Line Options

  • --title TEXT: Set the PDF title
  • --help: Show help message and exit
  • --version: Show version and exit

Example Markdown File

# My Document

This is a sample document with a Mermaid diagram.

```mermaid
graph TD
    A[Start] --> B{Is it?}
    B -- Yes --> C[OK]
    B -- No --> D[Cancel]

Documentation

Development

Running Tests

pytest

Code Style

This project uses:

  • Black for code formatting
  • isort for import sorting
  • mypy for type checking
  • ruff for linting

Run all checks:

pre-commit run --all-files

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mermaidmd2pdf-0.1.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mermaidmd2pdf-0.1.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file mermaidmd2pdf-0.1.0.tar.gz.

File metadata

  • Download URL: mermaidmd2pdf-0.1.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for mermaidmd2pdf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f6e9c558dd5cc51d1e178fbfd83cb603d05e86a2cb8a0913b495c5ca12896ced
MD5 f776c58a2cb3021b5be28025cf0c9f71
BLAKE2b-256 e2f390f88bba4976e0eb2e791040c28858e3ea729dc1b70d124c4e88cafa2552

See more details on using hashes here.

File details

Details for the file mermaidmd2pdf-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mermaidmd2pdf-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for mermaidmd2pdf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eea6e983721410ea192f591cf9fa27d121a7cfaa5caadffbc2bbefc7e5c84fb5
MD5 5fd5283ae6996a0982706737db1951d5
BLAKE2b-256 5d65ef02a285191aa8c80e5c10f76572621025391329caf64c447556ba580dc5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page