Skip to content

Repository files navigation

Markdown Mermaid Converter

A robust Python tool that converts Markdown files with Mermaid diagrams to PowerPoint (PPTX) and PDF formats without cutting any content.

Features

  • Large Diagram Support: Handles Mermaid diagrams up to 10M characters
  • No Content Clipping: Automatically scales diagrams to fit slides/pages
  • Smart Pagination: Proper page breaks for PDFs
  • PowerPoint Export: Creates professional presentations with proper slide layout
  • PDF Export: Generates PDFs with correct pagination
  • Code Block Support: Syntax-highlighted code blocks in both formats
  • Headless Rendering: Uses Playwright for consistent diagram rendering

Installation

  1. Clone the repository:
git clone <repository-url>
cd ppt
  1. Install dependencies:
pip install -r requirements.txt
  1. Install Playwright browsers:
playwright install chromium
# or use the built-in command:
python main.py --install-playwright

Usage

Basic Usage

Convert to both PowerPoint and PDF:

python main.py input.md

Convert to PowerPoint only:

python main.py input.md -f pptx

Convert to PDF only:

python main.py input.md -f pdf

Specify output filename:

python main.py input.md -o output_name -f both

Example

# Test with the included example
python main.py test_document.md

# This creates:
# - test_document.pptx
# - test_document.pdf

How It Works

  1. Parsing: Extracts content blocks (text, headings, code, mermaid) from Markdown
  2. Rendering: Uses Playwright to render Mermaid diagrams with proper sizing
  3. Export:
    • PowerPoint: Intelligent slide creation with automatic content fitting
    • PDF: Proper pagination with no content cutoff

Architecture

The system uses:

  • Playwright for headless browser-based Mermaid rendering
  • python-pptx for PowerPoint generation
  • ReportLab for PDF generation
  • Markdown for parsing with custom Mermaid extension

Requirements

  • Python 3.9+
  • Chromium (installed via Playwright)

License

MIT

About

Markdown + Mermaid to PowerPoint/PDF converter (Python)

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages