DEV Community

loading...

Exporting a markdown book to PDF with Pandoc (2)

Fernando B πŸš€
Coding space junkie with a sprinkle of writer heart. DMs open for any questions or comments. πŸ™‚
・1 min read

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!

Discussion (0)