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!

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

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

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❀️