---
title: HackMD to PDF with Pandoc
author: dev.to/apeunit
---
Full disclosure, I'm a big fan of Markdown, and also a big fan of [HackMD](https://hackmd.io) (and it's community fork [CodiMD](https://codimd.org)).
Now imagine you have to write a technical assessment or specifications and you started writing it down on hackmd/codimd because, you know, reasons 😤. But then, for the sake of the argument, let's say that you have to produce a deliverable artifact that can be shipped to someone, like a customer; then a link to a online document might just not cut it 🤔.
So what to do? Alright, easy solution, fire up [typora](https://typora.io/) (or similar), paste the markdown, File > Export > PDF. The day is saved.
You go back skimming through the news and you find this: [Writing a Book with Pandoc, Make, and Vim](https://keleshev.com/my-book-writing-setup/)
Wait a second... what if... 🤯 `vim Makefile`
```
AU_HACKMD_CODE = bfScafhcTdGzzhJ4B3evlQ
AU_OUTFILE = $(HOME)/$(AU_HACKMD_CODE).MD.$(shell date +%F).pdf
AU_FORMAT = article
hackmd2pdf:
@echo format doc
curl -s -L "https://hackmd.io/$(AU_HACKMD_CODE)/download" \
-o /tmp/$(AU_HACKMD_CODE).md
pandoc /tmp/$(AU_HACKMD_CODE).md -o $(AU_OUTFILE) \
--table-of-contents \
--pdf-engine=xelatex \
--highlight-style=monochrome \
--number-sections \
-V 'fontsize: 12pt' \
-V 'papersize: A4' \
-V 'urlcolor: blue' \
-V 'date: \today{}' \
-V 'documentclass:$(AU_FORMAT)' \
-V 'geometry:margin=3.8cm'
xdg-open $(AU_OUTFILE)
@echo done
```
and now ...
```
make hackmd2pdf HACKMD_CODE=bfScafhcTdGzzhJ4B3evlQ
```
BOOM![^deps][^pandoc]
Now, I do understand that from a pure aesthetic point of view this might not be enough to satisfy the sensitive eye of the graphic designer, but it can be shipped!

[^deps]: some dependencies need to be installed, on ubuntu `texlive-xetex` and `pandoc`
[^pandoc]: this command will not work for you, because it contains specific branding stuff from [Ape Unit](https://apeunit.com), but if you are looking for a simpler one look [no further](https://gist.github.com/noandrea/1082b6649d526d301980b97365691b1c)!