Skip to content

Releases: lancer-code/md2pdf

v1.0.1 — Network fallback for libavif

09 Apr 22:16

Choose a tag to compare

Problem v1.0.0 didn't solve

The v1.0.0 installer had a 2-tier fallback for the Ubuntu 24.04
libavif.so.16 problem:

  1. Look in system paths
  2. Search $HOME for vendored copies inside Python wheels (Pillow, OpenCV)

If you had neither a system libavif package nor any Pillow/OpenCV
anywhere in your home directory, the installer would give up
with a
sudo apt install libavif16 hint — which required root and didn't work
for every user (shared servers, restricted systems, no sudo).

The v1.0.1 fix

install.sh now has a third fallback: download a pre-built shim from the
md2pdf GitHub release over HTTPS
. The complete chain is:

# Source Requires
1 Prince runs as-is
2 System paths (/usr/lib/..., /usr/local/lib/...) distro libavif package
3 $HOME filesystem walk Pillow, OpenCV, or other vendored wheel
4 GitHub release download (NEW) curl + internet access
5 Clear platform-specific error with install instructions

The download is:

  • Self-contained — depends only on standard libc, libstdc++, libm
  • ELF-validated before staging so a mirror serving HTML error pages can't break the install
  • Version-pinned to v1.0.0 release assets (URL is permanent)
  • Linux x86_64 only — macOS and ARM Linux users get a platform-specific error with the correct brew / apt / dnf command

Other improvements

  • 10-second timeout on the $HOME filesystem walk so the installer can't hang on huge home directories or broken NFS mounts
  • Better error messages — every failure path now includes the exact command to run next (sudo apt install libavif16, brew install libavif, etc.)
  • Architecture detection — no more attempting to install an x86_64 shim on ARM
  • Documented fallback chain at the top of install.sh so readers can understand the logic without tracing the code

What's in the v1.0.0 release that v1.0.1 depends on

The v1.0.1 installer downloads these assets (originally attached to v1.0.0):

  • libavif-shim-linux-x86_64.so (5.1 MB) — pre-built libavif, BSD-2-Clause, self-contained
  • libavif-LICENSE — full license text from upstream libavif

These stay pinned to v1.0.0 for stability. The v1.0.1 release itself only contains updated source code (no asset changes).

Upgrade

cd md2pdf
git pull origin main
./install.sh

Or re-install from scratch:

git clone https://github.com/lancer-code/md2pdf.git
cd md2pdf
./install.sh

End-to-end test performed

Before shipping, I removed my local shim and re-ran ./install.sh on a
clean state. The installer correctly:

  1. Detected Prince failure
  2. Searched system paths — no match
  3. Searched $HOME — no match (after removal)
  4. Downloaded the shim from the v1.0.0 release
  5. Validated the ELF header
  6. Staged it at ~/.local/lib/prince-deps/libavif.so.16
  7. Re-ran prince --version successfully

Total time: ~3 seconds over decent bandwidth.


Full changelog: CHANGELOG.md
Compare: v1.0.0...v1.0.1

v1.0.0 — Initial release

09 Apr 22:06

Choose a tag to compare

First public release of md2pdf — a single-file bash script that converts Markdown to a print-ready PDF in one command, powered by Prince and marked.

Highlights

  • One command, one file in, one PDF out. md2pdf notes.mdnotes.pdf.
  • Print-optimized CSS baked in. A4 margins, running header, page-number footer, zebra-striped tables, wrapping code blocks, smart page breaks.
  • No global npm installs. marked is fetched on-demand via npx --yes marked@14 — no pollution of your global tree, pinned for reproducibility.
  • Idempotent installer. ./install.sh is safe to re-run any number of times.
  • Auto-detected libavif shim. On Ubuntu 24.04 where Prince fails to load libavif.so.16, the installer automatically finds a usable copy on your machine (including Pillow / OpenCV Python wheels that vendor their own) and stages it at ~/.local/lib/prince-deps/.
  • Helpful errors. Missing prince? Missing npx? Broken libavif? You get a clear one-line error that tells you exactly what to install.
  • Readable in one sitting. The entire converter is ~300 lines of bash and CSS — copy it anywhere, tweak it freely.

What's included

  • md2pdf — the portable single-file script
  • install.sh — idempotent installer with automatic libavif discovery
  • examples/sample.md + examples/sample.pdf — full feature showcase, rendered output committed so you can preview without installing
  • README.md — comprehensive documentation with install, usage, CSS customization guide, comparison with md-to-pdf / pandoc / WeasyPrint / mdpdf / wkhtmltopdf, libavif shim explainer, and troubleshooting
  • CONTRIBUTING.md — project philosophy and development workflow
  • CHANGELOG.md, LICENSE (MIT)

Quick start

git clone https://github.com/lancer-code/md2pdf.git
cd md2pdf
./install.sh

md2pdf examples/sample.md

Requirements

  • Prince — free for non-commercial use
  • Node.js ≥ 18 (for npx)
  • bash ≥ 4
  • Linux or macOS

Known limitations

  • Prince is not fully open source. Free for non-commercial use with a small watermark; paid for commercial use. See the Prince license FAQ.
  • marked is pinned to 14.x for reproducibility.
  • macOS users may need brew install coreutils for readlink -f.
  • WSL and Windows native bash are untested.

Why

Most Markdown-to-PDF tools either ship an entire headless Chromium (200 MB+) or require a full LaTeX installation (500 MB+). md2pdf uses Prince — a small purpose-built HTML-to-PDF engine with excellent print CSS support — to give you fast, deterministic output from a script you can read in ten minutes.

See the README's comparison table for an honest breakdown of when to pick md2pdf vs its alternatives.


Full changelog: CHANGELOG.md