Markpdf: a best in class Markdown -> PDF tool

Markpdf is currently part of GitHub - ralsina/markterm · GitHub (along with markterm and markmark)

It’s a markdown->PDF converter based on litehtml and libharu

It parses markdown using markd then takes the HTML and uses libhtml to do layout and finally libharu to create a PDF.

Some of the highlights:

  • Can create a 600 A4 page PDF of Brothers Karamazov in under 5 seconds.
  • Tables
  • Footnotes
  • Annotations
  • Fenced code blocks with syntax highlighting
  • Inline and display math (cheating via libtexprintf
  • Fully justified with hyphenation (includes implementation of the TeX hyphenation algorithm)
  • Outline based on headings
  • Multiple image types, including svg (requires external tool)
  • Inline HTML rendered
  • HTML blocks rendered
  • emoji, accents, CJK
  • Page breaking with widow heading prevention
  • Pageless mode: all your PDF is a single page. Yes, you can do a page with all of Brothers Karamazov in it.
  • CSS stylesheets (a few included, user can add customized)
  • Color schemes

There isn’t AFAIK, a tool with this much feature coverage that doesn’t involve installing chrome or TeX or Typst. Markpdf is a 9MB static binary.

Here is an example of how the output looks:

As someone who uses Pandoc with Docker, I’m somewhat interested in this tool, but I’m not sure if it’s right for me. A website where you can view sample PDFs created with markpdf might be helpful for people who are on the fence about trying it out.

There will be, at some point.