Generate PDF from markdown
md-to-pdf
Best solution so far:
- md-to-pdf
- Nodejs/Typescript, uses Marked and Puppeteer
- Last commit 2023
- No arch package, install:
npm i -g md-to-pdf
- Works well !
Usage:
md-to-pdf README.md --pdf-options '{ "format": "A4", "margin": "20mm" }'
Custom md2pdf.sh script
~/bin/md2pdf.sh
Custom script which generates a PDF from a/mulitple markdown files using pandoc
md2pdf.sh list.md -o list.pdf
Easypdf
- GitHub
- Last commit 2023, only 5 commits
Using pandoc
weasyprint engine
- Lightweight
- Works well
pdfroff
- Doesn't display checkboxes
(
troff: <standard input>:135: warning: can't find special character 'u2610'
)
wkhtmltopdf engine
- Ruby, pulls in ~500MB of dependencies
- Deprecated Github repo is archived
xelatex pdf-engine
- Latex, pulls in tons of dependencies
Recommended, has more options than texlive
.
Setup:
sudo apt install pandoc texlive-xetex texlive-fonts-recommended
Config (default fonts, formatting etc):
~/projects/markup/markdown/pandoc/pdf-defaults.tex
Generate:
pandoc -H ~/projects/markup/markdown/pandoc/pdf-defaults.tex \
--pdf-engine=xelatex -f gfm R.md -o R.pdf
include highlighting:
pandoc -H ~/projects/markup/markdown/pandoc/pdf-defaults.tex \
--pdf-engine=xelatex --highlight-style python test.md -o test.pdf
Using texlive
sudo apt-get install pandoc texlive-latex-extra
pandoc -f gfm ubuntu_16.10.md -o ubuntu_16.10.pdf
Syntax highlighting
List available styles:
pandoc --list-highlight-styles
pandoc --highlight-style=zenburn R.md -o R.pdf
Using a template together with .tex defaults:
pandoc ~/projects/markup/markdown/highlighting.md -o /tmp/highlighting.pdf \
--from markdown --template eisvogel --listings \
-H ~/projects/markup/markdown/pandoc/pdf-bulletpoints.tex
Syntax highlighting issues
luamark
- Github
- From the
pandoc
author - Not packaged in Arch
Currently HTML, dzslides (HTML5 slides), Docbook, ConTeXt, LaTeX, and Groff man are the supported output formats
Unmaintained tools
- md2pdf
- Python, based on
wkhtmltopdf
- Last commit 2022-01
- Python, based on
- markdown-pdf: Last commit 2019-08 (as of 2020-04)
- gimli - Development stalled since 2017