USP
It offers enhanced code block styling with syntax highlighting and professional tables with styled headers, going beyond basic Markdown-to-EPUB conversion for technical and structured content.
Use cases
- 01Converting research notes into readable ebooks
- 02Archiving blog posts or articles as EPUBs
- 03Transforming Claude chat summaries into portable documents
- 04Creating technical documentation with styled code blocks
- 05Generating device-agnostic reading material from any Markdown source
Detected files (1)
markdown-to-epub/SKILL.mdskillShow content (6599 bytes)
--- name: markdown-to-epub-converter description: Convert markdown documents and chat summaries into formatted EPUB ebook files that can be read on any device or uploaded to Kindle. --- # Markdown to EPUB Converter Skill This skill transforms markdown documents into professional EPUB ebook files. Perfect for converting research documents, blog posts, articles, or chat conversation summaries into portable, device-agnostic ebook formats. ## Overview The skill accepts markdown content in multiple formats and generates a properly formatted EPUB3 file that works across all major ebook readers including: - Apple Books - Amazon Kindle (via Kindle for Mac/Windows/iOS/Android) - Google Play Books - Kobo and other EPUB readers - Any standard EPUB reader ## Input Formats ### Option 1: Raw Markdown Text Provide markdown content directly in your message: ``` Convert this markdown to EPUB: # My Book Title ## Chapter 1 This is chapter one content... ``` ### Option 2: File Path Provide a path to a markdown file to be converted. ## How It Works 1. **Markdown Parsing**: Analyzes your markdown and automatically: - Treats H1 headers (`#`) as chapter boundaries - Treats H2 headers (`##`) as section headings within chapters - Preserves formatting (bold, italic, links, lists, code blocks) 2. **Structure Generation**: Creates proper EPUB structure: - Automatic table of contents from chapters - Navigation document (EPUB3 standard) - Metadata (title, language, etc.) 3. **File Creation**: Generates a valid EPUB3 file ready for download and use ## Usage Examples ### Example 1: Convert a Blog Post "Convert this markdown blog post to EPUB: # How to Build a Simple Web Server ## Introduction ...content..." ### Example 2: Convert a Research Summary "I have research notes in markdown format. Convert them to an EPUB ebook. The content is: # Research Project: Machine Learning Basics ## Chapter 1: Fundamentals ..." ### Example 3: Convert a Chat Summary "Summarize our conversation so far as markdown and convert it to an EPUB for reference" ## Output The skill generates a downloadable EPUB file that includes: - Professional formatting - Automatic table of contents - Proper chapter structure - Support for markdown formatting elements: - Headers (all levels) - Bold and italic text - Hyperlinks - Lists (ordered and unordered) - Code blocks and inline code - Blockquotes - Horizontal rules ## Markdown Elements Supported | Element | Markdown | Support | Notes | |---------|----------|---------|-------| | Headers | `# H1` through `###### H6` | Full | Auto TOC generation | | Bold | `**text**` or `__text__` | Full | | | Italic | `*text*` or `_text_` | Full | | | Links | `[text](url)` | Full | Clickable in ebooks | | Lists | `- item` or `1. item` | Full | Nested lists supported | | Code blocks | ` ```language ` | **Enhanced** | Syntax highlighting ready, monospace fonts | | Inline code | ` `code` ` | **Enhanced** | Styled background, borders | | Tables | Markdown tables | **Enhanced** | Styled headers, alternating rows | | Blockquotes | `> quote` | Full | Styled with left border | | Horizontal rule | `---` or `***` | Full | | ## Advanced Features ### Enhanced Code Block Support Code blocks are beautifully formatted with: - **Premium monospace fonts**: SF Mono, Monaco, Fira Code, Consolas, and more - **Styled backgrounds**: Subtle gray background with blue accent border - **Language detection**: Specify language after ` ``` ` for future syntax highlighting - **Proper escaping**: HTML characters are safely escaped - **Overflow handling**: Horizontal scrolling for long lines Example: ```python def fibonacci(n): if n <= 1: return n return fibonacci(n-1) + fibonacci(n-2) ``` ### Enhanced Table Support Tables are rendered with professional styling: - **Styled headers**: Blue background with white text - **Alternating rows**: Zebra striping for readability - **Cell padding**: Comfortable spacing for easy reading - **Inline formatting**: Code, bold, italic, and links work in cells - **Responsive**: Tables adapt to different screen sizes Example: | Feature | Status | Notes | |---------|--------|-------| | Headers | ✓ | Full support | | Code | ✓ | Enhanced styling | | Tables | ✓ | Professional layout | ### Custom Title and Metadata You can specify EPUB metadata: - Book title (defaults to first H1 header) - Author name - Language - Publication date ### Chapter Organization Chapters are automatically detected from: - H1 headers (`#`) as primary chapter breaks - Logical content sections between H1s - Automatic page breaks between chapters ### Styling The generated EPUB uses clean, readable default styling that: - Respects the reader's font preferences - Works on all screen sizes - Maintains proper spacing and hierarchy - Includes appropriate margins and padding ## Technical Details - **Format**: EPUB3 (compatible with all modern readers) - **Encoding**: UTF-8 - **HTML Version**: XHTML 1.1 - **CSS Support**: Responsive styling ## Downloading Your EPUB After generation, the file will be available for download. You can then: 1. Download the EPUB to your computer 2. Open it with your preferred ebook reader 3. Transfer to your Kindle, iPad, or other device 4. Upload directly to Kindle via email or cloud ## Tips for Best Results 1. **Use Proper Markdown Structure**: The skill works best when markdown follows standard conventions (H1 for titles, H2 for sections) 2. **Clear Chapter Breaks**: Use H1 headers to clearly mark chapter divisions 3. **Descriptive Headers**: Headers become the table of contents, so make them clear and descriptive 4. **Content Organization**: Place content logically between headers 5. **Supported Formatting**: Stick to basic markdown formatting for best compatibility across all readers ## Troubleshooting **EPUB doesn't open**: Ensure your markdown is properly formatted. Check for matching brackets in links and proper syntax. **Table of contents is empty**: Make sure your markdown includes H1 headers to define chapters. **Formatting looks different**: EPUB readers apply their own fonts and styling. This is normal and expected behavior. ## Scripts - `epub_generator.py` - Core EPUB file creation and formatting - `markdown_processor.py` - Markdown parsing and structure extraction ## Future Enhancements - Auto-generated cover pages with custom images - Kindle-specific optimizations (.mobi format) - Custom CSS styling per user preferences - Multi-document merging - Image embedding and optimization - Advanced metadata support
README
Markdown to EPUB Claude Skill
A Claude agent skill that converts markdown documents and chat summaries into professional EPUB ebook files. Perfect for creating portable, device-agnostic ebooks from research documents, blog posts, articles, or conversation summaries.
Overview
This skill transforms markdown content into EPUB3 format ebooks that work across all major reading platforms:
- Apple Books
- Amazon Kindle (via Kindle reading apps)
- Google Play Books
- Kobo
- Any standard EPUB reader
Features
✨ Markdown Processing
- Automatic chapter detection from H1 headers
- Automatic section parsing from H2-H6 headers
- Full markdown formatting support (bold, italic, links, lists, code blocks, etc.)
- Enhanced code blocks with premium monospace fonts and syntax highlighting support
- Professional tables with styled headers and alternating row colors
📚 EPUB Generation
- EPUB3 standard compliance
- Automatic table of contents with proper navigation
- Responsive, device-agnostic styling
- Proper document structure and metadata
- Beautiful code formatting for technical documents
🎯 Smart Input Handling
- Accept raw markdown text directly
- Process markdown files by path
- Extract metadata from YAML frontmatter
- Handle edge cases gracefully
Project Structure
markdown-to-epub/
├── SKILL.md # Skill definition with YAML frontmatter
├── requirements.txt # Python dependencies
├── scripts/
│ ├── markdown_processor.py # Markdown parsing & structure extraction
│ ├── epub_generator.py # EPUB file creation & formatting
└── resources/
└── default_styles.css # (future) Custom EPUB styling
test_epub_skill.py # Test suite with sample content
Installation
Prerequisites
- Python 3.8+
- pip (Python package manager)
Setup
-
Install dependencies:
pip install -r markdown-to-epub/requirements.txt -
Verify installation:
python test_epub_skill.pyYou should see all tests pass:
- ✓ Markdown processing: PASSED
- ✓ EPUB generation: PASSED
- ✓ Edge cases: PASSED
Usage
Basic Python Usage
from markdown_to_epub.scripts.epub_generator import create_epub_from_markdown
markdown_content = """
# My Book
## Chapter 1
Content here...
"""
# Generate EPUB
create_epub_from_markdown(
markdown_content,
output_path="my_book.epub",
title="My Book",
author="John Doe"
)
With Claude Skills Framework
When registered as a Claude skill, simply ask Claude to convert markdown to EPUB:
"Convert this markdown to an EPUB ebook:
# Research Summary
## Introduction
...content..."
Or provide a file path:
"Convert the markdown file at research_notes.md to an EPUB file"
Markdown Support
| Element | Example | Support | Styling |
|---|---|---|---|
| Headers | # H1 through ###### H6 | Full | Optimized sizes for e-readers |
| Bold | **bold** or __bold__ | Full | Strong emphasis |
| Italic | *italic* or _italic_ | Full | Subtle emphasis |
| Links | [text](url) | Full | Clickable |
| Lists | - item or 1. item | Full | Proper indentation |
| Code Blocks | ```language | Enhanced | Monospace fonts, styled backgrounds, blue accent |
| Inline Code | `code` | Enhanced | Gray background, subtle border |
| Tables | Markdown tables | Enhanced | Blue headers, zebra striping, responsive |
| Blockquotes | > quote | Full | Blue left border |
| Horizontal Rule | --- or *** | Full | Subtle divider |
| Paragraphs | Text with blank lines | Full | Justified text |
YAML Frontmatter Support
Add metadata to your markdown using YAML frontmatter:
---
title: My Ebook
author: John Doe
language: en
date: 2025-01-15
---
# Chapter 1
...
Supported fields:
title- Book titleauthor- Author namelanguage- Language code (default:en)date- Publication date
Architecture
MarkdownProcessor (markdown_processor.py)
- Parses markdown into structured chapters and sections
- Extracts metadata from YAML frontmatter
- Builds table of contents
- Converts markdown to HTML
- Handles edge cases (empty content, special characters, etc.)
EPUBGenerator (epub_generator.py)
- Creates valid EPUB3 files using ebooklib
- Manages book metadata and document structure
- Applies consistent styling via embedded CSS
- Generates navigation documents (NCX, NAV)
- Handles proper spine/TOC setup
Dependencies
- ebooklib (0.18.0) - EPUB file creation and manipulation
- markdown2 (2.4.12) - Markdown utilities (included for future enhancement)
Testing
Run the comprehensive test suite:
python test_epub_skill.py
Tests include:
- Markdown parsing with various header structures
- EPUB file generation and validation
- Edge cases (empty content, plain text, special characters)
- Long documents (10+ chapters)
- Table of contents generation
- Metadata extraction
Future Enhancements
🎨 Cover Page Generation
- Auto-generate title pages with styling
- Custom cover images with MCP integration
📱 Kindle Support
- .mobi and .azw3 format generation
- Kindle-specific optimizations
- Direct Kindle device upload capability
🎨 Advanced Styling
- Custom CSS per user preferences
- Custom fonts
- Advanced typography controls
📚 Multi-Document
- Merge multiple markdown files
- Cross-document references
- Advanced chapter organization
Technical Details
- EPUB Version: EPUB3 (2023 standard)
- HTML Standard: XHTML 1.1
- Character Encoding: UTF-8
- CSS Support: Responsive, embedded styling
- Navigation: NCX (compatibility) + NAV (EPUB3 standard)
Troubleshooting
EPUB won't open
- Verify markdown uses proper syntax
- Check for balanced brackets in links
- Ensure chapters have H1 headers
Missing table of contents
- Add H1 headers to mark chapter boundaries
- Verify headers are followed by content
Formatting looks different
- This is normal! EPUB readers apply their own fonts and styling
- Structure is preserved across all readers
Large file size
- Compress with external tools if needed
- Remove large embedded content if applicable
License
This skill follows the same license as the Claude Cookbooks project.
Contributing
Contributions are welcome! Areas for improvement:
- Additional markdown features (tables, footnotes)
- Enhanced styling options
- Performance optimizations
- Additional format support
Related Resources
Created: 2025-01-16 Version: 1.0.0 Status: Production Ready