Beautiful, configurable, extensible Markdown-to-PDF rendering for Python.
Project description
Markprint
Beautiful, configurable, extensible Markdown-to-PDF rendering for Python.
Markprint is designed as a real document compiler rather than a tiny conversion script. It accepts files, raw Markdown strings, stdin, batches, or multi-file manuals; renders Markdown into themed printable HTML; then converts that HTML into PDF through WeasyPrint by default, with optional Playwright and Pandoc backends for browser-rendered diagrams/math and academic workflows.
Highlights
- File input:
markprint README.md README.pdf - Inferred output:
markprint README.md - Raw string input:
markprint render-string "# Hello" --output hello.pdf - Stdin input:
echo "# Hello" | markprint - hello.pdf - Batch render:
markprint batch docs/*.md --out-dir dist/pdf - Compile mode:
markprint compile docs/intro.md docs/usage.md --output manual.pdf - Built-in themes: default, GitHub, Nord, Dracula, report, resume, academic
- Built-in profiles: docs, report, resume, academic, book, whitepaper
- Markdown frontmatter configuration
pyproject.toml,markprint.toml, and.markprint.tomldiscovery- Typer CLI with Rich output
- Pydantic v2 settings models
- Pygments code highlighting
- Optional
ultiloglogging backend - Optional Playwright, Pandoc, Python-Markdown, pypdf, pikepdf, and PyMuPDF extension points
Installation
pdm add markprint
From this repository:
pdm install -G dev -G test -G docs
pdm run markprint README.md README.pdf
Full local development install:
pdm install -G all
pdm run playwright install chromium
Quickstart
markprint README.md README.pdf
markprint README.md --theme github --toc
markprint render-string "# Hello\n\nThis is **Markdown**." --output hello.pdf
cat README.md | markprint - README.pdf
Python API
from pathlib import Path
from markprint import RenderOptions, render_pdf
artifact = render_pdf(
markdown="# Hello\n\nThis is **raw Markdown**.",
output=Path("hello.pdf"),
options=RenderOptions(theme="github", toc=True),
)
print(artifact.output_path)
Configuration
Markprint reads configuration from:
- CLI flags
- Python API
RenderOptions - Markdown frontmatter
markprint.toml,.markprint.toml, or[tool.markprint]inpyproject.toml- Built-in defaults
Example:
[tool.markprint]
default_input = "README.md"
default_output = "dist/README.pdf"
engine = "weasyprint"
markdown_engine = "markdown-it"
theme = "github"
profile = "docs"
toc = true
page_numbers = true
code_theme = "default"
page_size = "Letter"
margin = "0.8in"
[tool.markprint.logging]
enabled = true
backend = "ultilog"
preset = "dev"
level = "INFO"
mode = "rich"
Frontmatter example:
---
title: Architecture Report
profile: report
theme: nord
toc: true
page_numbers: true
---
# Overview
CLI reference
markprint [INPUT] [OUTPUT]
markprint render INPUT [OUTPUT]
markprint render-string MARKDOWN --output OUTPUT
markprint batch INPUTS... --out-dir DIR
markprint compile INPUTS... --output OUTPUT
markprint html INPUT --output OUTPUT.html
markprint themes
markprint profiles
markprint engines
markprint config
markprint doctor
Architecture
MarkdownSource
→ FrontmatterParser
→ MarkdownEngine
→ HtmlDocument
→ HtmlBuilder + ThemeRegistry + Pygments
→ StyledHtmlDocument
→ PdfRenderer
→ PdfArtifact
Strict boundaries keep the package extensible:
- Markdown engines never know about PDF rendering.
- PDF renderers never know about Markdown syntax.
- Themes only provide templates and CSS.
- Logging is optional and adapter-based.
- Heavy dependencies live behind extras.
Testing
pdm run pytest
pdm run pytest --cov=markprint --cov-report=term-missing
The repository includes unit, integration, e2e, and visual test scaffolds.
Optional extras
pdm add "markprint[logging]" # ultilog
pdm add "markprint[browser]" # Playwright
pdm add "markprint[pandoc]" # pypandoc
pdm add "markprint[markdown-python]"# Python-Markdown + pymdown-extensions
pdm add "markprint[pdf]" # pypdf, pikepdf, PyMuPDF
pdm add "markprint[all]" # everything
Development roadmap
- Strengthen config precedence and theme inheritance
- Add more Markdown plugins and custom admonitions
- Add Mermaid pre-render mode
- Add MathJax/KaTeX browser rendering
- Add Pandoc citation workflows
- Add PDF metadata/merge/preview commands
- Add plugin discovery through entry points
- Add visual regression fixtures
License
MIT
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
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 markprint-0.1.5.tar.gz.
File metadata
- Download URL: markprint-0.1.5.tar.gz
- Upload date:
- Size: 33.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7fe0c285aadf392ef29d309cdd5663b6891a18d8b8fdd3c58a1248d4290c93c
|
|
| MD5 |
99e392ff05e66b29bfb62964c7b4e8b6
|
|
| BLAKE2b-256 |
f92fb47dd6c29772e72c7775cfe84ea3b2e71bf92e0ca9320304d83125d56ed0
|
Provenance
The following attestation bundles were made for markprint-0.1.5.tar.gz:
Publisher:
release.yml on pr1m8/markprint
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
markprint-0.1.5.tar.gz -
Subject digest:
b7fe0c285aadf392ef29d309cdd5663b6891a18d8b8fdd3c58a1248d4290c93c - Sigstore transparency entry: 1417303218
- Sigstore integration time:
-
Permalink:
pr1m8/markprint@865ad0a6f208baf6d57650d1d0fadf3eede6fdb3 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/pr1m8
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@865ad0a6f208baf6d57650d1d0fadf3eede6fdb3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file markprint-0.1.5-py3-none-any.whl.
File metadata
- Download URL: markprint-0.1.5-py3-none-any.whl
- Upload date:
- Size: 52.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a42ef903572705d6572313a4ad7362bdfdda6bccf9bd8716e9cfb8e1857a893a
|
|
| MD5 |
f3d7e793dd56a737ae7eabc4b0fee637
|
|
| BLAKE2b-256 |
75e2ceb6f54452219ebfad626b28d35624cdef39f0636324196b278d90edbd07
|
Provenance
The following attestation bundles were made for markprint-0.1.5-py3-none-any.whl:
Publisher:
release.yml on pr1m8/markprint
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
markprint-0.1.5-py3-none-any.whl -
Subject digest:
a42ef903572705d6572313a4ad7362bdfdda6bccf9bd8716e9cfb8e1857a893a - Sigstore transparency entry: 1417303234
- Sigstore integration time:
-
Permalink:
pr1m8/markprint@865ad0a6f208baf6d57650d1d0fadf3eede6fdb3 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/pr1m8
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@865ad0a6f208baf6d57650d1d0fadf3eede6fdb3 -
Trigger Event:
release
-
Statement type: