3 ms·
I use Weasyprint [1] to generate a PDF from HTML, and I use a self-written static site generator based on Python & Jinja2 to convert Markdown to HTML first [2]
by ThePhysicist 3y ago
I use Weasyprint [1] to generate a PDF from HTML, and I use a self-written static site generator based on Python & Jinja2 to convert Markdown to HTML first [2] (note: that code is undocumented and only used by me). Weasyprint can handle code highlighting e.g. using Pygments or another static framework, the only downside is it can't execute JS so if you e.g. want to dynamically generate content to render like SVGs you need to first pass your HTML through a headless browser, which is also possible though. There's also paged.js [3] which is similar but runs in the browser, so it supports JS-generated content out of the box. And as others have mentioned Pandoc [4] is the Swiss army knife of converting between document formats.
1: https://weasyprint.org/ https://weasyprint.org/
2: https://github.com/adewes/beam-up https://github.com/adewes/beam-up
3: https://pagedjs.org/ https://pagedjs.org/
4: https://pandoc.org/ https://pandoc.org/