mdfusion
A Python module for merging and exporting Markdown files. Available for pip.
When I am studying for exams, I often end up with a lot of Markdown files in a folder hierarchy. For revising the content, I want to merge these files into one single file and have them in a nicely readable format.
When looking for a solution, I did not find a tool that would crawl the directory for me, merge the files and export them to a PDF or HTML file in one go. So I wrote a small Python module that does exactly that. Since I feel like this is a common use case, I decided to publish it on GitHub and PyPI.
The code is available on GitHuband on PyPI.
Even though this is a small project, I manage it in a git repository using
Merge all Markdown files in a directory tree into a single PDF with beautiful formatting via Pandoc + XeLaTeX.
.md
files under a directory (natural sort order)..mdfusion
INI-style config file for repeatable builds.header.tex
if desired.pip install mdfusion
mdfusion
package:pip install ./mdfusion
mdfusion ROOT_DIR [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 filemdfusion --title-page --title "My Book" --author "Jane Doe" docs/
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
Run all tests with:
pytest
Feel free to leave your opinion or questions in the comment section below.