How Can I Convert Github-Flavored Markdown To A PDF

I've had success using grip to display markdown in Chrome and then use Chrome's "Save as PDF" option in the Print dialog.

pip install grip  
grip your_markdown.md

grip will render the markdown on localhost:5000 or similar (ex: go to http://localhost:5000/) - just edit away and refresh the browser. Print when ready.

This gave a more reliable representation than pandoc and was lighter weight than installing latex (required by pandoc for pdf generation).

The print is not command-line in this answer, but still found this easier/more reliable (looked 100% like Github for a long document including relatively linked images and code highlighting).


You can also use Node.js based markdown-pdf

npm install -g markdown-pdf
markdown-pdf /path/to/markdown

Take a look at pandoc. It does have syntax highlighting. It might require you making (minor) changes to your document since it has its own flavour of markdown and I don't know how closely it matches the GitHub flavour.

Tags:

Pdf

Markdown