This page looks best with JavaScript enabled

Create eBook from Multiple Markdown Files

 ·   ·  ☕ 2 min read

I had been a fan of LeanPub. The platform promises easy book authoring using Markdown, and distribute the book to a hungry audience.

However, I am not a big fan of how Markdown is processed in LeanPub. Markua, the flavor (created &) preferred by LeanPub, is not completely aligned to how GitHub and others process the Markdown. I encountered a few problems including images and could not do a lot of experimentation since LeanPub limits book previews / generation to 20 times a month in the free plan.

Since I planned to collaborate on this book with a community in the future, I decided to align to the GitHub standards rather than create external dependencies.

This brought about another problem. It is easy to use Pandoc or something similar to create PDF/MOBI/ePUB format when you have a singe document. What if you had structured different chapters in separate files?

It is not a difficult problem since you know at a gut level this can be solved with a few additional parameters. But it took close to two hours to find out just what will work in the most efficient manner (for Windows).

Here is the solution -

  1. Create a folder structure that is sensible.
    I used -
    [contains book files]
    -> publish [misc. files used for publishing]
    -> build [folder that is created in runtime for the generated books.

  2. I used MikTeX for Latex engine to generate PDF.

  3. Created a Windows batch file to run the end-to-end commands

I uploaded the files used to to GitHub. Check out and let me know what you think.

Create PDF/ePUB from multiple markdown files.

The solution is very similar to an old repository but works well for Windows (and also considers the changes to Pandoc over the last five years!).

Stay in touch!
Share on

Prashanth Krishnamurthy
Prashanth Krishnamurthy
Technologist | Creator of Things