Convert Markdown files to beautifully styled PDFs
Project description
๐ markd2pdf
Transform your Markdown into beautifully styled PDFs
Features โข Installation โข Usage โข Themes โข Configuration
โจ Features
- ๐จ 5 Themes โ Professional dark, Dracula, Nord, GitHub Dark, and Minimal Light
- ๐ Batch Processing โ Convert entire directory trees recursively
- ๐๏ธ Syntax Highlighting โ Full code block highlighting powered by Pygments
- ๐ Rich Markdown โ Tables, admonitions, footnotes, TOC, abbreviations, and more
- โก Parallel Processing โ Multi-threaded conversion for speed
- ๐ฏ Single File Mode โ Convert individual files or entire directories
๐ฆ Installation
Prerequisites
-
Python 3.12+
-
System dependencies for WeasyPrint:
# Arch / Manjaro sudo pacman -S pango gdk-pixbuf2 # Debian / Ubuntu sudo apt install libpango-1.0-0 libgdk-pixbuf-2.0-0 # macOS brew install pango gdk-pixbuf
Install from PyPI
pip install markd2pdf
Or with uv:
uv tool install markd2pdf
Install from Source (Development)
git clone https://github.com/ramcharan/markd2pdf.git
cd markd2pdf
uv sync # or: pip install -e .
๐ Usage
Quick Start
# Convert a single file
markd2pdf convert README.md ./output
# Convert an entire directory
markd2pdf convert ./docs ./pdf-output
# Use a specific theme
markd2pdf convert ./docs ./output --theme dracula
Commands
Usage: markd2pdf [OPTIONS] COMMAND [ARGS]...
Commands:
convert Convert Markdown files to PDFs
themes List all available themes
Convert Command
Usage: markd2pdf convert [OPTIONS] INPUT_PATH OUTPUT_DIR
Arguments:
INPUT_PATH Markdown file or directory to convert [required]
OUTPUT_DIR Directory to save the generated PDFs [required]
Options:
-t, --theme [github_dark|dracula|nord|minimal_light|professional_dark]
CSS theme to use for styling [default: github_dark]
--help Show this message and exit
Examples
# Convert all markdown files in a directory
markd2pdf convert ~/Documents/notes ~/Documents/pdfs
# Convert with the Nord theme
markd2pdf convert ~/notes ~/pdfs -t nord
# Convert a single file with Dracula theme
markd2pdf convert ./README.md ./output --theme dracula
# List available themes
markd2pdf themes
๐จ Themes
| Theme | Description |
|---|---|
github_dark |
GitHub-inspired dark theme (default) |
dracula |
Dracula color scheme with neon accents |
nord |
Arctic-inspired, easy on the eyes |
minimal_light |
Clean light theme for printing |
professional_dark |
Sophisticated dark with blue accents |
Preview themes:
markd2pdf themes
โโโโโโโโโโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Theme Name โ Description โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ github_dark โ GitHub-inspired dark theme (default) โ
โ dracula โ Dracula color scheme with neon โ
โ nord โ Arctic-inspired, easy on the eyes โ
โ minimal_light โ Clean light theme for printing โ
โ professional_dark โ Sophisticated dark with blue accents โ
โโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ๏ธ Configuration
Customizing Themes
All theme stylesheets are in the styles/ directory. To create a custom theme:
-
Create a new CSS file:
cp styles/professional_dark.css styles/my_theme.css
-
Edit the theme in
main.py:class Theme(str, Enum): professional_dark = "professional_dark" dracula = "dracula" minimal_light = "minimal_light" nord = "nord" github_dark = "github_dark" my_theme = "my_theme" # Add your theme
-
Add a description:
THEME_DESCRIPTIONS = { # ...existing themes... Theme.my_theme: "My custom theme description", }
Markdown Extensions
markd2pdf supports these Markdown extensions out of the box:
| Extension | Description |
|---|---|
tables |
GitHub-style tables |
fenced_code |
Triple-backtick code blocks |
codehilite |
Syntax highlighting |
toc |
Table of contents with [TOC] |
admonition |
Note/warning/tip blocks |
footnotes |
Footnote references |
attr_list |
HTML attributes on elements |
def_list |
Definition lists |
abbr |
Abbreviations |
md_in_html |
Markdown inside HTML blocks |
๐ ๏ธ Development
# Clone the repo
git clone https://github.com/yourusername/markd2pdf.git
cd markd2pdf
# Install dev dependencies
uv sync --group dev
# Run linters
uv run black main.py
uv run isort main.py
uv run mypy main.py
# Run pre-commit hooks
uv run pre-commit run --all-files
๐ License
MIT License โ see LICENSE for details.
Made with โค๏ธ and Python
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file markd2pdf-0.1.0.tar.gz.
File metadata
- Download URL: markd2pdf-0.1.0.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3e2b88b6aac2e32dbfc40e966b55ff497646465124b3e4a2863bbc746e2847f
|
|
| MD5 |
1463b8722c74e4084fc3ced04815509c
|
|
| BLAKE2b-256 |
28cab37647da14d68731a0496f7cfd0492a8724424490a40e5ef3bf97b68f4dd
|
File details
Details for the file markd2pdf-0.1.0-py3-none-any.whl.
File metadata
- Download URL: markd2pdf-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e1e37d618008c13bd91c0a4848dbc0af898eaa2c0603698e64ed76e6cc9ff9d
|
|
| MD5 |
88e7b56a5988af54ce5b1a1dd21a2128
|
|
| BLAKE2b-256 |
4ce27d3c09c646ba4c3fc40d51b98dc7125d7f5ca21a8bb64f1525bbcf897a60
|