Merge Markdown files into a single PDF or HTML presentation with Pandoc + XeLaTeX
Project description
mdfusion
Merge all Markdown files in a directory tree into a single PDF or HTML presentation with formatting via Pandoc + XeLaTeX.
Features
- Recursively collects and sorts all
.mdfiles under a directory (natural sort order) - Merges them into one document, rewriting image links to absolute paths (so images with the same name in different folders don't collide)
- Optionally adds a title page with configurable title, author, and date
- Supports both PDF (via Pandoc + XeLaTeX) and HTML presentations (via reveal.js)
- Customizes output with your own LaTeX or HTML headers/footers
- Configurable via TOML for repeatable builds (great for books, reports, or slides)
- Bundles HTML presentations with all assets for easy sharing
Installation
Requirements
You must have the following on your PATH:
For HTML presentations and PDF export from HTML, you may also want to install:
- Playwright (for HTML→PDF conversion) via
pip install playwrightand thenplaywright install
Install via pip
pip install mdfusion
Install from source
git clone https://github.com/ejuet/mdfusion.git
cd mdfusion
pip install .
Usage
mdfusion [OPTIONS]
You can also pass extra Pandoc arguments at the end of the command; any unknown flags are forwarded to Pandoc.
Common options
--root_dir DIRRoot directory for Markdown files (default: current directory, or config file directory)--output FILEOutput filename (default:<root_dir>.pdfor.htmlfor presentations)--tocInclude table of contents (use--notocto disable)--title_pageInclude a title page (PDF only)--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)--config_path FILEPath to amdfusion.tomlconfig file (default:mdfusion.tomlin the current directory)--header_tex PATHCustom LaTeX header to include (defaults to./header.texif present)--merged_md DIRWrite merged Markdown to this directory (uses a temp dir by default)--remove_alt_texts TXTComma-separated list of image alt texts to strip (default:alt text)--verboseEnable verbose Pandoc output
Presentation options
--presentationOutput as a reveal.js HTML presentation (also converts to PDF)--footer_text TEXTCustom footer for presentations--animate_all_linesAdd reveal.js fragment animation to each line--chromium_path PATHPath to Chromium for HTML→PDF conversion (default:/usr/bin/chromium)
Example: Merge docs/ into a PDF with a title page
mdfusion --root_dir docs --title_page --title "My Book" --author "Jane Doe"
Example: Create a reveal.js HTML presentation
mdfusion --root_dir slides --presentation --title "My Talk" --author "Speaker" --footer_text "My Conference 2025"
Configuration file
You can create a mdfusion.toml file in your project directory to avoid long command lines. The [mdfusion] section supports all the same options as the CLI. Presentation-only settings live under [presentation] (these can also remain under [mdfusion] for backward compatibility).
Example: Normal document (PDF)
[mdfusion]
root_dir = "docs"
output = "my-book.pdf"
toc = true
title_page = true
title = "My Book"
author = "Jane Doe"
pandoc_args = ["--number-sections", "--slide-level", "2", "--toc-depth", "4"]
# header_tex = "header.tex" # Optional: custom LaTeX header
Example: Presentation (HTML via reveal.js)
[mdfusion]
root_dir = "slides"
output = "my-presentation.html"
title = "My Talk"
author = "Speaker"
pandoc_args = ["--slide-level", "6", "--number-sections", "-V", "transition=fade", "-c", "custom.css"]
# You can add more reveal.js or pandoc options as needed with ["-V", "option=value"]
[presentation]
presentation = true
footer_text = "My Presentation 2025"
animate_all_lines = false
# chromium_path = "/usr/bin/chromium"
Then just run:
mdfusion
How it works
- Finds and sorts all Markdown files under the root directory (natural order)
- Merges them into one file, rewriting image links to absolute paths
- Optionally adds a YAML metadata block for title/author/date
- Calls Pandoc with XeLaTeX (for PDF) or reveal.js (for HTML presentations)
- Optionally bundles HTML output with all assets for easy sharing
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
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.3.3.tar.gz.
File metadata
- Download URL: mdfusion-0.3.3.tar.gz
- Upload date:
- Size: 42.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95c8a993d54a8a4152b466787c85084471163d26e75e858e1fdcd0e81c1e7266
|
|
| MD5 |
b7c75c6edfce77909a2cc7334853bf2a
|
|
| BLAKE2b-256 |
411c703c9e7b51fb8d8612645b09f9995235bba8ff5f79a50e0eafc2b65362a8
|
File details
Details for the file mdfusion-0.3.3-py3-none-any.whl.
File metadata
- Download URL: mdfusion-0.3.3-py3-none-any.whl
- Upload date:
- Size: 40.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad460cf0333cc586b7a1b62890e7b33eac870d9d5e891f642b835ad545dabca8
|
|
| MD5 |
89e494b92da88cd3ce4da31639a8d474
|
|
| BLAKE2b-256 |
8463be018fab0bbf0eda8e61f63f898b5f010ce1ad8dfd1e6b8bfa1890a5fc67
|