Python-based book production system for creating professional PDF and EPUB books from Markdown.
- PDF Generation — WeasyPrint with CSS Paged Media (dot-leader TOCs, running headers, page counters)
- EPUB3 Generation — Valid e-books with embedded fonts
- 4-File Structure — FrontMatter.md, Content.md, Backmatter.md, Decisions.md
- Typography System — 11+ font pairs, 5 density presets, smart quotes/dashes
- Print-on-Demand — Lulu and Pumbo specifications built-in
- Quality Checks — Pagination analysis for widows/orphans, preflight validation
git clone https://github.com/yourusername/bookcrafter.git
cd bookcrafter
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt- Create an instance for your book:
mkdir -p instances/my-book/content instances/my-book/styles instances/my-book/output- Copy and edit the sample files:
cp content/*.md instances/my-book/content/
cp book_config.py instances/my-book/-
Edit
instances/my-book/book_config.pywith your book's metadata. -
Build:
python build.py build -i my-book -f pdf
python build.py build -i my-book -f epub
python build.py build -i my-book -f all# Build
python build.py build -i <instance> -f pdf|epub|html|all|screen
# With platform specs
python build.py build -i <instance> -t lulu:paperback_6x9_bw
python build.py build -i <instance> -t pumbo:a5_paperback_roman
# With typography
python build.py build -i <instance> -y playfair-lora:relaxed
# Quality checks
python build.py check -i <instance>
python build.py preflight -i <instance>
# Preview
python build.py preview -i <instance>
python build.py watch -i <instance>
# List available options
python build.py instances
python build.py lulu-products
python build.py pumbo-products
python build.py typography-fonts
python build.py typography-densitiesbookcrafter/
├── build.py # Main CLI
├── book_config.py # Default config template
├── content/ # Sample content files
├── styles/
│ ├── base.css # Core typography
│ └── brand.css # Default colors/fonts
├── fonts/ # Embedded fonts
├── instances/ # Your book projects (gitignored)
│ └── my-book/
│ ├── book_config.py
│ ├── content/
│ ├── styles/
│ │ └── brand.css # Color overrides
│ ├── assets/
│ └── output/ # Built files
└── tools/ # Quality checkers
# cover
::title:: Your Book Title
::subtitle:: A Subtitle
::author:: Author Name
# title-page
::title:: Your Book Title
...
# copyright
Copyright text...
# dedication
*For someone special.*
# toc# Part I: Introduction
## Chapter 1: Getting Started
Your content here...
## Chapter 2: Next Chapter# bibliography
## References
...
# about-author
## About the Author
...| Font Pair | Style |
|---|---|
| playfair-lora | Classic serif |
| merriweather-lato | Modern mixed |
| inter-source-sans | Clean sans |
| libre-baskerville-crimson | Traditional |
Density: tight, snug, normal, relaxed, loose
Usage: -y playfair-lora:relaxed
MIT