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 formatting via Pandoc + XeLaTeX.
Features
- Recursive Markdown merge: Collects and sorts all
.mdfiles 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.tomlconfig file for repeatable builds. - Custom LaTeX header: Inject your own LaTeX via
header.texif 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
- Clone this repo
- Install Python 3.8+ and Pandoc with XeLaTeX support
- Install the
mdfusionpackage:
pip install ./mdfusion
Usage
mdfusion ROOT_DIR [OPTIONS]
Common options
-o, --output FILEOutput PDF filename (default:<root_dir>.pdf)--no-tocOmit table of contents--title-pageInclude a title page--title TITLESet title for title page (default: directory name)--author AUTHORSet author for title page (default: OS user)--pandoc-args ARGSExtra Pandoc arguments (whitespace-separated)-c, --config FILEPath to amdfusion.tomlconfig file (default:mdfusion.tomlin the current directory)
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
Project details
Release history Release notifications | RSS feed
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.8.tar.gz
(7.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mdfusion-0.1.8.tar.gz.
File metadata
- Download URL: mdfusion-0.1.8.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6bd5809a01c95e3fffeb9b1fed2c9a8270d3f902ac442ab690729fd08a81c75
|
|
| MD5 |
4075f59394281102d96149d8218515c3
|
|
| BLAKE2b-256 |
281dba8dbab5cef56a3b14df2ad922fe3a6d8fcdcbfc04c0d380f6ca44a57262
|
File details
Details for the file mdfusion-0.1.8-py3-none-any.whl.
File metadata
- Download URL: mdfusion-0.1.8-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef84546e5d3f6637552f61a8de32488167ec8fc7b456a9d138c2e85fccfebede
|
|
| MD5 |
5c6e426ec9f1c71fb9e13cc78d9eb62e
|
|
| BLAKE2b-256 |
f2ce15e0641d0488757ff7b9eb5171a5fdb30400c2b4185d51da8c3861cfa9bc
|