Convert Markdown to PDF

Lately, I wrote a small text in markdown and felt the need to share it with someone (non-technical). I searched for solutions to convert markdown to PDF and was very surprised, that there were only so-so solutions. After some googling and coding I found an easy to use solution which comprises a markdown tool for converting markdown to html and phantomJS (a headless WebKit scriptable) for converting html to pdf. The cool things: hyperlinks and custom css work.

If you are on a mac, you can use homebrew for installing the dependencies (on linux distributions you should have a corresponding package manager):

brew install markdown phantomjs

Then create a new bash script markdown2pdf.sh (and chmod 751 it, so that it is executable):