Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

md2pdf

Small command-line converter from Markdown to PDF. It renders A4 documents with a compact built-in stylesheet and supports the Python-Markdown extra, codehilite, and sane_lists extensions.

Requirements

  • Python 3.10 or newer.
  • uv for dependency and environment management.
  • The native libraries required by WeasyPrint.

On Apple Silicon macOS, the script includes /opt/homebrew/lib in the dynamic library search path. Homebrew dependencies must still be installed separately.

Setup

uv sync --locked

If the machine has a private package index configured globally, isolate this project from that configuration and select PyPI explicitly:

env -u UV_INDEX -u UV_DEFAULT_INDEX -u UV_INDEX_URL \
  -u UV_EXTRA_INDEX_URL -u UV_CONFIG_FILE \
  uv sync --locked --no-config --default-index https://pypi.org/simple

Usage

Create a PDF next to the source file:

uv run --frozen md2pdf document.md

Choose the output path explicitly:

mkdir -p output
uv run --frozen md2pdf document.md --output output/document.pdf

The input file must exist. If --output is omitted, its .md suffix is replaced with .pdf.

Repository layout

  • md2pdf.py: converter, command-line interface, and PDF stylesheet.
  • pyproject.toml: package metadata, dependencies, and md2pdf entry point.
  • uv.lock: reproducible dependency resolution.
  • input.md and input.pdf: optional local scratch files, intentionally ignored by Git.
  • output/: optional directory for generated PDFs, also ignored by Git.

Development check

There is no automated test suite yet. After a change, at minimum run:

uv run --frozen md2pdf --help
mkdir -p output
uv run --frozen md2pdf input.md --output output/input.pdf

Use a real Markdown fixture for the second command; input.md is not part of the repository.

About

Small command-line converter from Markdown to PDF

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages