DEV Community

Fernando B ๐Ÿš€
Fernando B ๐Ÿš€

Posted on

Exporting a markdown book to PDF with Pandoc (2)

This is a revisit of my old post. I wanted to update it, since I updated my python script to generate a pdf.

  • Fixed printing md files out of order
  • Two options for folder structure
    • Chapters with folders, with scenes as md files
    • Chapters as md

LaTex, and pandoc are great but for your typical writer that isn't a software dev or has 3 Master degrees learning how to compile a bunch of markdown files isn't super straightfoward, latex, xelatex, templates, packages, and the list goes on. Can you imagine if after writing a thesis on Word Doc, you had to learn how to write a yaml file in order to print you document.

https://github.com/kodaman2/markdown-book

Anyways I won't beat the horse the tools above are great, but do require some learning overhead, and this is troublesome if you just want to write and print. The markdown-book repo shows you how to have chapter directories, or just markdown files. It has a python script ready for a basic pdf to get you started. Surely there's more work to do like have some css files to make everything prettier.

Using directories for chapters:

โ”œโ”€โ”€โ”€title.txt
โ”œโ”€โ”€โ”€Chapter1
โ”œโ”€โ”€โ”€Chapter2
โ””โ”€โ”€โ”€images
Enter fullscreen mode Exit fullscreen mode

New addition to the export_book.py script, now it supports md files without chapter directories:

โ”œโ”€โ”€โ”€title.txt
โ”œโ”€โ”€โ”€Chapter1.md
โ”œโ”€โ”€โ”€Chapter2.md
โ””โ”€โ”€โ”€images
Enter fullscreen mode Exit fullscreen mode

Let me know what you think about the repo. Thanks for reading!

Top comments (0)