EPUB Builder
Convert markdown documents into a professional EPUB3 ebook file that opens in any
reader: Apple Books, Amazon Kindle (Kindle app), Google Play Books, Kobo, etc.
When to use
- User has markdown (research notes, articles, blog post, docs) and wants an
.epub.
- "Turn this into an ebook", "make a Kindle file", "convert to EPUB".
- "Summarize our chat as markdown and export it as an ebook for reference."
What it produces
A valid EPUB3 file with:
- Chapters auto-split on
# (H1), sections on ## (H2).
- Auto table of contents + EPUB3 nav document.
- Metadata (title, author, language). Title defaults to first H1.
- Styled rendering of bold, italic, links, ordered/unordered (nested) lists,
code blocks (monospace, accent border), inline code, tables (zebra rows,
styled headers), blockquotes, horizontal rules.
How to run
The skill is two importable Python modules, not a CLI. Get them from the source repo:
markdown-to-epub/scripts/epub_generator.py and markdown_processor.py
(github.com/smerchek/claude-epub-skill). Place both in the working dir.
Install deps (pin to known-good versions):
python3 -m pip install ebooklib==0.18.0 markdown2==2.4.12 Pygments==2.17.2
Convert — the simplest path is the convenience function:
from epub_generator import create_epub_from_markdown
# markdown_content can be read from a file or passed inline
ok = create_epub_from_markdown(
markdown_content, # raw markdown string
"output.epub", # output path
title="My Book", # optional; falls back to first H1
author="Author Name", # optional
)
For finer control (custom metadata, language, reusing parsed chapters), use the
classes directly: MarkdownProcessor().process(md) returns {'metadata', 'chapters'}, then EPUBGenerator(metadata).generate(chapters, output_path).
Authoring tips for clean output
- Use H1 (
#) for chapter breaks — these become TOC entries and page breaks.
- Use H2 (
##) for sections inside a chapter.
- Make headers descriptive; they ARE the table of contents.
- Stick to standard markdown for cross-reader compatibility.
Gotchas
- Empty TOC = no H1 headers in the source. Add
# chapter headings.
- EPUB doesn't open = malformed markdown (e.g. unmatched link brackets). Validate syntax.
- Fonts/styling differ per reader — readers apply their own; this is expected, not a bug.
- Memory use is ~3-5x the markdown source size for large documents.
- HTML special chars in content are escaped automatically.
Not (yet) supported
Cover-image generation, image embedding, .mobi output, syntax-highlight colors
(language tag is captured but rendered monospace only), multi-document merge.
1---2name: epub-builder3description: "Use when asked to convert markdown/notes/docs/research/blog posts/chat summaries into an EPUB ebook (.epub), make a Kindle/Apple Books/Kobo-readable book, build an ebook from markdown, or generate an EPUB3 file with chapters and a table of contents."4version: 1.0.05license: MIT6tags: [epub, ebook, markdown, kindle, apple-books, converter, documents, publishing, epub3]7source: https://github.com/smerchek/claude-epub-skill8derived_from: awesomeclaude9prerequisites:10 commands: [python3]11metadata:12 source: https://skillmd.com/skills/aashutosh396/epub-builder13---1415# EPUB Builder1617Convert markdown documents into a professional EPUB3 ebook file that opens in any18reader: Apple Books, Amazon Kindle (Kindle app), Google Play Books, Kobo, etc.1920## When to use2122- User has markdown (research notes, articles, blog post, docs) and wants an `.epub`.23- "Turn this into an ebook", "make a Kindle file", "convert to EPUB".24- "Summarize our chat as markdown and export it as an ebook for reference."2526## What it produces2728A valid EPUB3 file with:29- Chapters auto-split on `#` (H1), sections on `##` (H2).30- Auto table of contents + EPUB3 nav document.31- Metadata (title, author, language). Title defaults to first H1.32- Styled rendering of bold, italic, links, ordered/unordered (nested) lists,33 code blocks (monospace, accent border), inline code, tables (zebra rows,34 styled headers), blockquotes, horizontal rules.3536## How to run3738The skill is two importable Python modules, not a CLI. Get them from the source repo:39`markdown-to-epub/scripts/epub_generator.py` and `markdown_processor.py`40(github.com/smerchek/claude-epub-skill). Place both in the working dir.4142Install deps (pin to known-good versions):4344```bash45python3 -m pip install ebooklib==0.18.0 markdown2==2.4.12 Pygments==2.17.246```4748Convert — the simplest path is the convenience function:4950```python51from epub_generator import create_epub_from_markdown5253# markdown_content can be read from a file or passed inline54ok = create_epub_from_markdown(55 markdown_content, # raw markdown string56 "output.epub", # output path57 title="My Book", # optional; falls back to first H158 author="Author Name", # optional59)60```6162For finer control (custom metadata, language, reusing parsed chapters), use the63classes directly: `MarkdownProcessor().process(md)` returns `{'metadata',64'chapters'}`, then `EPUBGenerator(metadata).generate(chapters, output_path)`.6566## Authoring tips for clean output6768- Use H1 (`#`) for chapter breaks — these become TOC entries and page breaks.69- Use H2 (`##`) for sections inside a chapter.70- Make headers descriptive; they ARE the table of contents.71- Stick to standard markdown for cross-reader compatibility.7273## Gotchas7475- Empty TOC = no H1 headers in the source. Add `#` chapter headings.76- EPUB doesn't open = malformed markdown (e.g. unmatched link brackets). Validate syntax.77- Fonts/styling differ per reader — readers apply their own; this is expected, not a bug.78- Memory use is ~3-5x the markdown source size for large documents.79- HTML special chars in content are escaped automatically.8081## Not (yet) supported8283Cover-image generation, image embedding, .mobi output, syntax-highlight colors84(language tag is captured but rendered monospace only), multi-document merge.