Skip to main content

Merge Markdown files into a single PDF with Pandoc + XeLaTeX

Project description

mdfusion

Merge all Markdown files in a directory tree into a single PDF with beautiful formatting via Pandoc + XeLaTeX.


Features

  • Recursive Markdown merge: Collects and sorts all .md files under a directory (natural sort order).
  • PDF output via Pandoc + XeLaTeX: Produces a polished PDF with centered section headings and small margins.
  • Title page and metadata: Optional title page with configurable title, author, and date.
  • Config file support: Use a .mdfusion INI-style config file for repeatable builds.
  • Custom LaTeX header: Inject your own LaTeX via header.tex if desired.
  • Image link rewriting: Converts relative image links to absolute paths, so identically-named images in different folders don't collide.

Installation

Install via pip

pip install mdfusion

Install from source

  1. Clone this repo
  2. Install Python 3.8+ and Pandoc with XeLaTeX support
  3. Install the mdfusion package:
pip install ./mdfusion

Usage

mdfusion ROOT_DIR [OPTIONS]

Common options

  • -o, --output FILE Output PDF filename (default: <root_dir>.pdf)
  • --no-toc Omit table of contents
  • --title-page Include a title page
  • --title TITLE Set title for title page (default: directory name)
  • --author AUTHOR Set author for title page (default: OS user)
  • --pandoc-args ARGS Extra Pandoc arguments (whitespace-separated)
  • -c, --config FILE Path to a .mdfusion INI-style config file

Example

mdfusion --title-page --title "My Book" --author "Jane Doe" docs/

Configuration file

You can create a .mdfusion file in your project directory:

[mdfusion]
root_dir = docs
output = my-book.pdf
no_toc = true
title_page = true
title = My Book
author = Jane Doe
pandoc_args = --number-sections

Then just run:

mdfusion

How it works

  • Finds and sorts all Markdown files under the root directory
  • Merges them into one file, rewriting image links to absolute paths
  • Optionally adds a YAML metadata block for title/author/date
  • Inserts page breaks between files
  • Calls Pandoc with XeLaTeX and a custom header for formatting

Testing

Run all tests with:

pytest

Author

ejuet

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdfusion-0.1.5.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mdfusion-0.1.5-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file mdfusion-0.1.5.tar.gz.

File metadata

  • Download URL: mdfusion-0.1.5.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for mdfusion-0.1.5.tar.gz
Algorithm Hash digest
SHA256 1bb17e7cdfb7511bc2dc9593a3bdd10d3e90749d6d92aac72a0217bee53f4dda
MD5 745aa59655b59efad99790b2ad9b7a3f
BLAKE2b-256 e87ee36b170ffff1a235ceb661825c3be2149059d21d3819d42b973676ae287f

See more details on using hashes here.

File details

Details for the file mdfusion-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: mdfusion-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for mdfusion-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 590cd6ee493b67b4584d3f11a60446fbe7edfbd12b6f972b6548c0c8711673ae
MD5 81c2ef1d77a23a10b82b8e73d4098867
BLAKE2b-256 773f2b2647a81adc7401e22259a4274df39908d9c72f4de81b38268ecce3c927

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page