Skip to main content

Convert Markdown files to EPUB

Project description

convertmd2epub

Convert Markdown files to EPUB — a simple CLI for authors and technical writers.

Python 3.12+ License MIT CI

Prerequisites

  • Python 3.12 or later
  • pip (included with Python)

On macOS, check your Python version:

python3 --version

If Python is not installed or too old, install it via python.org or Homebrew:

brew install python@3.12

Installation

With pip (recommended)

pip install .

With pipx (isolated install)

pipx install .

Development mode

pip install -e ".[dev]"

Quickstart

1. Create your Markdown chapters

mkdir my-book && cd my-book

Create a few .md files:

cat > ch01-introduction.md << 'EOF'
# Introduction

Welcome to my book.
EOF

cat > ch02-getting-started.md << 'EOF'
# Getting Started

Let's begin.
EOF

2. Generate the configuration

convertmd2epub init

This scans the directory for .md files and generates a book.toml:

[book]
title = "Mon Livre"
author = "Author"
language = "fr"

[book.chapters]
files = [
    "ch01-introduction.md",
    "ch02-getting-started.md",
]

Edit book.toml to set your title, author, and language.

3. Build the EPUB

convertmd2epub build

Your EPUB is ready at book.epub. Open it with Apple Books, Calibre, or any EPUB reader.

CLI Reference

convertmd2epub init [DIRECTORY] [--force]
Option Description
DIRECTORY Directory containing .md files (default: .)
--force, -f Overwrite existing book.toml
convertmd2epub build [--config PATH] [--verbose]
Option Description
--config, -c Path to book.toml (default: book.toml)
--verbose, -v Show detailed output and validation result

Configuration Reference

[book] — Book metadata

Field Type Required Default Description
title string yes Book title
author string yes Author name
language string no "en" Language code (BCP 47)
subtitle string no Subtitle
description string no Book description
cover string no Path to cover image (JPEG or PNG)
output string no "book.epub" Output file path

[book.chapters] — Chapter list

Field Type Required Description
files list of strings yes Ordered list of Markdown files

[options] — Build options

Field Type Default Description
toc boolean true Generate table of contents
toc_depth integer 2 Heading depth for TOC (1–6)
css string Path to custom CSS file
no_default_css boolean false Disable built-in e-ink CSS
validate_epub boolean true Validate EPUB structure after build

Minimal example

[book]
title = "My Book"
author = "Jane Doe"

[book.chapters]
files = ["chapter1.md", "chapter2.md"]

Full example

[book]
title = "The Complete Guide"
author = "Jane Doe"
language = "en"
subtitle = "Everything you need to know"
description = "A comprehensive guide."
cover = "cover.jpg"
output = "dist/guide.epub"

[book.chapters]
files = [
    "00-preface.md",
    "01-introduction.md",
    "02-getting-started.md",
    "03-advanced-topics.md",
    "04-appendix.md",
]

[options]
toc = true
toc_depth = 3
css = "custom.css"
validate_epub = true

Troubleshooting

command not found: convertmd2epub

Your Python scripts directory may not be in your PATH. Try:

python3 -m convertmd2epub --help

Or add the scripts directory to your PATH:

export PATH="$HOME/.local/bin:$PATH"

Add this line to ~/.zshrc to make it permanent.

No module named 'convertmd2epub'

Make sure you installed the package:

pip install .

Wrong Python version

If you have multiple Python versions, use python3.12 explicitly:

python3.12 -m pip install .

Supported Markdown Features

  • Headings (H1–H6)
  • Paragraphs, bold, italic, strikethrough
  • Ordered and unordered lists
  • Code blocks (fenced and indented)
  • Links and images (local files)
  • Tables
  • Blockquotes
  • Footnotes

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

convertmd2epub-0.2.0.tar.gz (7.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

convertmd2epub-0.2.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file convertmd2epub-0.2.0.tar.gz.

File metadata

  • Download URL: convertmd2epub-0.2.0.tar.gz
  • Upload date:
  • Size: 7.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for convertmd2epub-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9b445efd53accf0b89a985badc214f8c912a93de84670f12ac4e19d1ed058134
MD5 73905a1155c4270c42d95275bbd7949b
BLAKE2b-256 5a5871d15ea1d42a2403fc23592b7f589fb6e5b9d007f7f04b57dd4bcfa56494

See more details on using hashes here.

Provenance

The following attestation bundles were made for convertmd2epub-0.2.0.tar.gz:

Publisher: publish.yml on thibmonier/convertmd2epub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file convertmd2epub-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: convertmd2epub-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for convertmd2epub-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c46f78ed24deab7c83375fb779702d3bb2ee13cd17b6b20465e296bb3fee370
MD5 3e7e97f4a3d9371771de353054773285
BLAKE2b-256 82b0dbdb286a185ec618ae97748bb96a8b8b50a2386145fbe832fe166219ff3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for convertmd2epub-0.2.0-py3-none-any.whl:

Publisher: publish.yml on thibmonier/convertmd2epub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page