DEV Community

Fernando B πŸš€
Fernando B πŸš€

Posted on

1 2

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!

πŸ‘‹ While you are here

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay