DEV Community

Leonardo Salas
Leonardo Salas

Posted on

I got tired of LaTeX, so I built a zero-config Python CLI to turn Markdown into premium PDFs

Have you ever just wanted to turn your standard README.md into a nice, academic-looking PDF without having to install a 2GB LaTeX environment or write a 500-line config file? Same here.

I was tired of dealing with complex setups just to export some documentation, so I built a pure Python solution: doc-engine-cli.

doc-engine-cli demo

How it works under the hood

I used mistune to parse the Markdown AST natively and safely in memory. Then, instead of hooking it up to a classic HTML-to-PDF engine (which usually misplaces margins and page breaks), I routed the parsed blocks directly into the lightning-fast Typst compiler engine via its python bindings.

The result:

  • Zero friction: It automatically detects your README.md and even extracts your local git config user.name for the cover page metadata.
  • Premium Typography: I shipped it with default Inter (sans-serif) and Cascadia Code typography to make code blocks look beautiful.
  • Smart elements: Dynamic Table of Contents, syntax-highlighted code fences, and proper page breaks out of the box.

Try it out!

You can install it instantly and securely via pipx:

pipx install doc-engine-cli
Enter fullscreen mode Exit fullscreen mode

And just run

doc-engine build --open
Enter fullscreen mode Exit fullscreen mode

in any folder with a markdown file.

If you don't even want Python installed, I've also containerized it on GHCR:

docker run --rm -v ${PWD}:/workspace ghcr.io/leonardosalasd/doc-engine-cli:main
Enter fullscreen mode Exit fullscreen mode

I'd absolutely love to hear your feedback, bug reports, or feature requests.

  • 🐙 GitHub: leonardosalasd/doc-engine-cli
  • 📦 PyPI: doc-engine-cli on PyPI

Let me know what you think of the Typst integration!

Top comments (0)