Introducing m1book, a tiny tool for turning Markdown into books
After writing my last booklet and fine-tuning my editing process, I decided to create a small program to formalize my setup. It’s now on Github: m1book.
My process hardly changed since I wrote about my first booklet in January this year. At that time I wrote a Ruby Rake task that converted my Markdown files into a PDF file using Pandoc. Although that setup worked, I didn’t like having the Rake task live next alongside my Markdown files. For the first project it was fine, but when editing my second booklet I found it didn’t scale. I just copied over the Rake task files to a new directory and focussed on finishing the booklet, knowing I would revise the code later.
So this is what I came up with. After installing m1book as a binstub using the ./install.sh script, it’s as easy as running m1book new <name of the book> to start off a new book project. This will scaffold a folder structure with a couple of example files and a config file. After changing into the newly created directory, running m1book generate will use Pandoc to squash all the Markdown files into a nice looking PDF. By editing config.yml some book settings, like the title, can be changed. The book is split up into front and main matter. Page numbers will only show in the main matter, but counting starts from the very first page. Just like in a book!
I’ve included the default PDF in the repository to showcase how it looks like once it’s generated. It’s really all I need for the upcoming book projects I have in mind.