Turn Markdown chapters into a beautiful, paginated book you can read in the browser or export as PDF
Project description
mkbooks
Turn Markdown chapters into a beautiful, paginated book you can read in the browser or export as PDF.
Features
- Markdown → Book — Write chapters in
.mdfiles, build a complete book with cover, TOC, and chapter navigation - Interactive Reader — Swipe gestures, keyboard shortcuts, and tap zones for a native reading experience on any device
- PDF Export — Generate print-ready PDFs with proper page breaks, headers, footers, and margins (via Playwright + PagedJS)
- Light / Dark Themes — Switch reading modes instantly
- Single & Spread Layouts — One-page or two-page spread view, auto-detected based on screen size
- Reading Progress — Automatically saves and restores your chapter and page across sessions
- Auto-generated Cover — Styled cover from your title, subtitle, and author — or bring your own image
- Drop Caps — Optional decorative first letters on chapter openings
- Live Reload —
mkbooks servewatches your files and rebuilds on every change - Fully Configurable — Page size, margins, fonts, colors, and layout via
mkbooks.yml
Installation
# With uv (recommended)
uv tool install mkbooks
# Local development
uv pip install -e .
Quick Start
# Create a new project
mkbooks new my-book
# Enter the project
cd my-book
# Add chapters
mkbooks add-chapter "Introduction"
mkbooks add-chapter "The Beginning"
# Build the book
mkbooks build
Commands
mkbooks new <name>
Creates a new project in a new folder.
mkbooks new my-book
mkbooks new my-book --title "My Great Book" --chapters 3
Options:
-t, --title— Book title (default: project name)-n, --chapters— Number of initial chapters (default: 1)
mkbooks init
Creates a project in the current directory.
mkbooks init
mkbooks init --title "My Book" --chapters 2
Options:
-d, --directory— Target directory (default:.)-t, --title— Book title-n, --chapters— Number of initial chapters
mkbooks add-chapter <title>
Adds a new chapter to the book.
mkbooks add-chapter "New Chapter"
mkbooks add-chapter "My Chapter" --file intro.md
Options:
-c, --config— Configuration file-f, --file— Custom filename
mkbooks build
Generates the HTML book (and optionally PDF).
mkbooks build
mkbooks build --no-open
mkbooks build --pdf
mkbooks build --config another-book.yml
Options:
-c, --config— Configuration file--no-open— Don't open browser automatically--pdf— Generate a PDF version (requiresmkbooks[pdf], see below)
mkbooks serve
Builds and serves the book with live reload.
mkbooks serve
mkbooks serve --port 8000
Options:
-c, --config— Configuration file-p, --port— Server port (default: 8765)
Configuration
The mkbooks.yml file defines the book structure and style:
book:
title: "My Book"
subtitle: "An incredible story"
author: "Your Name"
language: "en"
year: "2026"
# Cover (optional - if no image, an automatic cover is generated)
cover:
image: "cover.jpg" # Optional
title_color: "#ffffff"
background_color: "#1a1a2e"
# Chapters
chapters:
- file: chapter-1.md
title: "Introduction"
- file: chapter-2.md
title: "The Beginning"
# Styles
style:
page:
size: "A5"
margin_top: "20mm"
margin_bottom: "25mm"
margin_inner: "25mm"
margin_outer: "20mm"
font:
body_family: "Georgia, 'Times New Roman', serif"
body_size: "11pt"
heading_family: "'Helvetica Neue', Arial, sans-serif"
chapter_title_size: "28pt"
line_height: "1.6"
drop_cap: true
chapter_break: "always"
# Output
output:
directory: "output"
filename: "book"
open_browser: true
Cover
- With image: Set
cover.imagewith the path to your image - Without image: An automatic cover is generated with title, subtitle, and author
PDF Export
Generate a print-ready PDF directly from the command line:
mkbooks build --pdf
This requires the optional pdf extra and Chromium:
pip install mkbooks[pdf]
playwright install chromium
The PDF is rendered via headless Chromium using PagedJS, preserving all page layout, headers, footers, and margins from your configuration.
Reader Navigation
The built-in reader supports multiple input methods:
| Method | Action |
|---|---|
| Swipe left / right | Next / previous page (touch devices) |
| Tap right side | Next page |
| Tap left side | Previous page |
| Tap center | Toggle toolbar |
| ← → keys | Previous / next page |
| Home / End | Jump to start / end of book |
Reading position is saved automatically and restored on next visit.
Requirements
- Python 3.12+
- (Optional)
mkbooks[pdf]+ Playwright for PDF generation
License
MIT
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 mkbooks-0.1.0.tar.gz.
File metadata
- Download URL: mkbooks-0.1.0.tar.gz
- Upload date:
- Size: 710.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3db2dacecc3c0758b11e749d13ee35e83de2979489f45766ce42433b71aaa0b7
|
|
| MD5 |
dd2ac262a7b33d071b1a11ad5fb06bbf
|
|
| BLAKE2b-256 |
4e930b126505ab7ccbf2035f447dbf7ca0a78333d3a202c03f98792fd2bcebba
|
File details
Details for the file mkbooks-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mkbooks-0.1.0-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e8fae560976641b2d8ec9cef689d6cd064e86a81ad022a8135fa0ab650f67a7
|
|
| MD5 |
7634134d1754451b2bd0f435db6d03cc
|
|
| BLAKE2b-256 |
ec4fd86993e735a7b34a40d206c2c2f805e6169010202753a165fb3680870758
|