For a year or 2 now I have been on the hunt for a way to be able to print out documents written in markdown, specifically Github Flavoured Markdown (GFM). I am a big fan of markdown, it takes away a majority of formatting clutter and lets you focus on simply writing. GFM works great for coding worksheets as really all you need are:
- Normal text
- Code blocks (and preferably syntax highlighting)
9/10 times I simply don’t need anything else.
The Raspberry Pi Foundation have been for quite a while developing their resources in markdown. The resources are added to their Github account and from there, every so often they are pulled and rendered on the Raspberry Pi Resources section.
I have used a number of their excellent resources and printed them directly from the resources section of their site, but what has been more of an issue is if I want to edit the resources, making a few changes simply for our Raspberry Jam or if I want to write my own.
For quite a while I wasn’t able to find any easy way to nicely rendering and printing worksheets I had written in markdown, so ended up switching back to Microsoft Word.
To write my markdown documents, I use Github Atom, an excellent (free and open source) general purpose text editor. It has a built in markdown renderer (hit ctrl + shift + m to open it) which displays the markdown documents as they will look like on Github. Atom though does not have any way built in of printing these.
I happened to be having a look through popular Atom plugins and stumbled across Markdown-Themeable-PDF. Markdown-Themeable-PDF is a plugin for Github Atom that allows you to really easily generate a beautiful looking PDF from your markdown, including full support for images.
How to install/use it
- First make sure you have Github Atom installed, you can download it from here.
- Open Github Atom, go to the settings and select Install.
Search for Markdown-Themeable-PDF and hit the install button beside it.
- Open your markdown document you want to export to PDF.
- Hit ctrl+shift+e to export it. It will save a PDF with the same filename (plus .pdf) in the folder you are working in.
You may also want to fiddle with the automatic header and footer, details on that can be found on the Markdown-Themeable-PDF page.
I have personally disabled the header and only left the page number in the footer.
I have used the Tweeting Babbage activity from the Raspberry Pi Foundation as an example as I have tweaked it for the NI Raspberry Jam.