Handy Markdown Productivity Scripts
04 April 19

For a couple of years I’ve been writing in markdown instead of using tools like Google Docs and Microsoft Word.

It was a gradual process and requried trial and error, but ultimately I believe writing in markdown has many benefits for people writing content for web, or for anyone who needs to produce lengthy documents that require consistent formatting.

My role at Coder Academy involves producing a large amount of written documentation and I’ve developed a script that takes a folder of markdown documents and turns them into a single PDF with a table of contents.

It’s a simple script that relies on Pandoc, WkHTMLtoPDF and an HTML template. There’s also the option to have YAML file with metadata that can be placed anywhere you like in the template.

More detailed instructions on its use can be found in my Handy Markdown Functions repo on Github.


pandoc -s *.md -f markdown -t html5
--template $htmlTemplate --section-divs
--metadata-file meta.yaml -V
current_date="$(date +%d-%m-%Y%n)" |
wkhtmltopdf --outline --outline-depth '2'
 --margin-bottom '20' --footer-font-name 
 'HelveticaNeue-Regular' --footer-left 
 '[doctitle] generated [date] at [time]' 
 --footer-right 'Page [page] of [toPage]' 
 --footer-font-size '8' --footer-spacing '5' 
 toc --xsl-style-sheet './toc.xsl' - $outputFileName

Check out a test document and see if it suits your workflow.

If using a script is beyond your level of IT tolerance, check out the markdown editor I use called Typora - it’s a what you see is what you get editor with plenty of themes, and lots of different options to export your markdown as HTML and PDFs.

Feel free to reach out to me on Twitter if you want a hand getting this workflow going with your documents.


< Return to posts