Markdown to book using Pandoc
I recently had a booklet printed. For creating the interior pages I wrote a small Ruby script that turns a collection of Markdown files into a PDF using Pandoc.
The script can be found on Github (markdown-pandoc-book). To get a quick impression see this PDF.
My needs for the booklet were limited and so is the script. It gives me:
- A distinction between front and main matter
- A simple title page (title, subtitle, author)
- A page with a quote
- A table of contents
- No page numbers in the front matter
- Page numbering starts where the main matter starts, with an offset
- A way to squeeze in blank pages
The script needs a source folder with front and main matter text files and a destination to write to. When run it concatenates all files into a front.txt
and main.txt
which are fed to the Pandoc command. The arguments of the Pandoc command are as straight forward as can be, setting the documentclass
, geometry
, language
and a couple of other variables.
The Latex template I used is almost identical to the default Pandoc Latex template, with one addition to remove the page numbering on the page with the table of contents itself.
I hope to see the repo evolve over time, because that probably means I’ve started another book project.