Skip to main content

Beautiful, configurable, extensible Markdown-to-PDF rendering for Python.

Project description

Markprint

PyPI Python CI Release Docs License

Markprint is a beautiful, configurable, extensible Markdown-to-PDF renderer for Python.

It is built for developers who want polished PDFs from Markdown without giving up control over themes, profiles, syntax highlighting, document metadata, batch rendering, logging, or advanced rendering backends.

Markdown source
  -> frontmatter and config
  -> parsed document model
  -> HTML body
  -> themed printable HTML
  -> PDF artifact

Why Markprint?

Markdown-to-PDF tooling often falls into two extremes. Some tools are easy but plain. Others are powerful but heavy, requiring Pandoc, LaTeX, browser automation, or lots of project-specific glue. Markprint aims for a better middle path:

  • simple by default,
  • beautiful out of the box,
  • deeply configurable when needed,
  • extensible through clean rendering stages,
  • useful as both a CLI and Python library.

Installation

pip install markprint

With optional extras:

pip install "markprint[logging]"
pip install "markprint[browser]"
pip install "markprint[pandoc]"
pip install "markprint[pdf]"

For local development:

pdm install -G dev -G test -G docs

Quickstart

Render a Markdown file to PDF:

markprint README.md README.pdf

Render raw Markdown:

markprint render-string "# Hello Markprint" --output hello.pdf

Render from stdin:

echo "# Hello from stdin" | markprint - hello.pdf

Compile multiple Markdown files into one PDF:

markprint compile docs/intro.md docs/usage.md docs/api.md --output manual.pdf

Python API

from pathlib import Path

from markprint import RenderOptions, render_pdf

render_pdf(
    source=Path("README.md"),
    output=Path("README.pdf"),
    options=RenderOptions(theme="github", profile="docs", toc=True),
)

Raw Markdown:

from markprint import render_pdf

render_pdf(
    markdown="# Hello

This is **raw Markdown**.",
    output="hello.pdf",
)

Documentation

Core features

  • Markdown file, raw string, stdin, batch, and multi-file input
  • YAML frontmatter and project config support
  • Themeable Jinja HTML templates
  • Pygments syntax highlighting
  • WeasyPrint backend by default
  • Optional Playwright and Pandoc backends
  • Optional ultilog logging integration
  • PDF helper extension points
  • Plugin-oriented architecture

Development

pdm install -G dev -G test -G docs
pdm run ruff check .
pdm run ruff format --check .
pdm run pytest --cov=markprint --cov-report=term-missing
pdm run mkdocs build --strict

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

markprint-0.1.6.tar.gz (32.8 kB view details)

Uploaded Source

Built Distribution

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

markprint-0.1.6-py3-none-any.whl (51.7 kB view details)

Uploaded Python 3

File details

Details for the file markprint-0.1.6.tar.gz.

File metadata

  • Download URL: markprint-0.1.6.tar.gz
  • Upload date:
  • Size: 32.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for markprint-0.1.6.tar.gz
Algorithm Hash digest
SHA256 2f6369c990eec9092b908c040dc00bb0aa3cec0865279b485cd52f7394a164df
MD5 6d9c860ea2be949e87fe8c48f5efd1a8
BLAKE2b-256 1b0a8c944993824837ac29cbef22c9b23d0a00f618b1fdbf87ac369872f6781f

See more details on using hashes here.

Provenance

The following attestation bundles were made for markprint-0.1.6.tar.gz:

Publisher: release.yml on pr1m8/markprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file markprint-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: markprint-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 51.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for markprint-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9042a0aaac052522cf70847c97b47d3027f5c0eaf060fd19e2a3dd6919ddd468
MD5 0cec02e97fc2de6499a823d97fd97d8d
BLAKE2b-256 c1d35671ff3953fd0e0f51be48c11481ff559fe2208b72b8d07f5b02a5b48551

See more details on using hashes here.

Provenance

The following attestation bundles were made for markprint-0.1.6-py3-none-any.whl:

Publisher: release.yml on pr1m8/markprint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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