I have recently started learning Markdown for use with documentation, and need to print out a few of my Markdown pages. I would like to use a command-line, Terminal, etc. utility that allows me to convert Github-flavored Markdown to PDF. It needs to have proper syntax highlighting and should not look horrible. Thanks for any help.
I've had success using grip to display markdown in Chrome and then use Chrome's "Save as PDF" option in the Print dialog.
grip will render the markdown on 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).
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.
As I stated in my comment, Github uses Linguist to provide syntax highlighting. On Github, you can use this to specify syntax highlighting like so:
Unfortunately, there's no good way to convert Markdown directly to a PDF file with syntax highlighting.
If you have vim, you can easily achieve syntax highlighting by running the following from a terminal:
Or inside of vim:
This will produce a PostScript file that can be converted to pdf using, for example, ps2pdf:
A few example Source-highlight commands include:
Using this input file
And each outputting their own respective HTML file:
Further examples of Source-highlight usage can be found here
If the markdown file was hosted on github repository, gitprint is an interesting option to create pdf / print.
All you need to do is to replace
Unfortunately, it does not work on markdown gists, and works only with markdown files at the repository.