A powerful text-to-EPUB conversion tool
Project description
MyEPUBApp
A powerful and flexible text-to-EPUB conversion tool that transforms plain text files into standard EPUB e-book format with advanced features for content processing and validation.
โจ Features
- ๐ Text to EPUB Conversion: Convert plain text files to fully EPUB-compliant e-books
- ๐ Chinese Content Support: Specially optimized for Chinese content with automatic Chinese book title mark conversion
- ๐ Intelligent Chapter Detection: Automatically identify and split chapters using special marker symbols
- ๐ Flexible Operation Modes: Support for creating new EPUB files or appending chapters to existing ones
- โ EPUB Validation: Built-in EPUB format validation with detailed compliance checking
- ๐๏ธ Modular Architecture: Clean, maintainable code structure for easy extension
- ๐ Comprehensive Logging: Detailed operation logging with configurable log levels
- ๐จ Cover Image Support: Add custom cover images to your EPUB files
- ๐ Table of Contents: Automatic generation of navigation and table of contents
๐ Installation
Requirements
- Python 3.8 or higher
- pip package manager
Option 1: Install from PyPI (Recommended)
pip install myepubapp
Option 2: Install from Source
- Clone the repository:
git clone https://github.com/eyes1971/myepubapp.git
cd myepubapp
- Install dependencies:
pip install -r requirements.txt
- Install in development mode:
pip install -e .
๐ Usage
Basic Usage
1. Create New EPUB File
myepubapp -i input.txt --output-epub output.epub
Automatic Title Generation: Book titles are automatically generated from input filenames (e.g., my_book.txt becomes "My Book")
2. Append Chapters to Existing EPUB
myepubapp -a input.txt --input-epub existing.epub --output-epub updated.epub
3. Validate EPUB File
myepubapp -v --input-epub file.epub
Command Line Options
| Option | Short | Description |
|---|---|---|
--init |
-i |
Initialize mode: create new EPUB file |
--append |
-a |
Append mode: add chapters to existing EPUB |
--validate |
-v |
Validate EPUB file format and structure |
input_file |
Input text file path (not required for validate mode) | |
--input-epub |
-ie |
Existing EPUB file (required for append/validate modes) |
--output-epub |
-o |
Output EPUB file path |
--convert-tags |
-ct |
Convert <> tags to Chinese book title marks ใใ |
--cover |
-c |
Path to cover image file |
Input File Format
Text files should use special marker symbols for chapter organization:
โปโ Introduction Title
This is the introduction content.
It can span multiple paragraphs and will be displayed as a separate introduction page.
โปโ
ฐ Chapter 1 Title
Chapter content goes here...
Multiple paragraphs are supported.
โปโ
ฑ Chapter 1 Section 1
Subsection content...
โปโ
ฒ Chapter 1 Section 1 Subsection 1
Deeper level content with full formatting support.
Marker Symbols:
โปโ: Introduction page (creates separate intro page)โปโ ฐ: Level 1 chapter (h1 heading)โปโ ฑ: Level 2 chapter (h2 heading)โปโ ฒ: Level 3 chapter (h3 heading)
๐ Examples
Create Simple EPUB
myepubapp -i sample.txt --output-epub mybook.epub
Create EPUB with Chinese Tag Conversion
myepubapp -i sample.txt --output-epub mybook.epub --convert-tags
Add Cover Image
myepubapp -i sample.txt --output-epub mybook.epub --cover cover.jpg
Append Chapters to Existing EPUB
myepubapp -a chapter2.txt --input-epub mybook.epub --output-epub mybook_updated.epub
Validate EPUB File
myepubapp -v --input-epub mybook.epub
๐๏ธ Project Structure
myepubapp/
โโโ core/ # Core business logic
โ โโโ __init__.py
โ โโโ book.py # EPUB book management
โ โโโ chapter.py # Chapter data structures
โ โโโ metadata.py # EPUB metadata handling
โโโ generators/ # Content generation modules
โ โโโ __init__.py
โ โโโ content.py # Content processing and chapter generation
โ โโโ toc.py # Table of contents generation
โโโ utils/ # Utility modules
โ โโโ __init__.py
โ โโโ epub_validator.py # EPUB format validation
โ โโโ file_handler.py # File I/O operations
โ โโโ logger.py # Logging configuration
โ โโโ text_processor.py # Text processing utilities
โโโ exceptions/ # Custom exception classes
โ โโโ __init__.py
โ โโโ epub_exceptions.py # EPUB-specific exceptions
โโโ cli.py # Command-line interface
โโโ __init__.py # Package initialization
โโโ py.typed # Type hints marker
๐ Dependencies
ebooklib>=0.18.0: Core EPUB file processing and manipulationbeautifulsoup4>=4.12.0: HTML/XML parsing and manipulation
๐ Validation Features
The built-in EPUB validator checks:
- โ File structure compliance
- โ Required metadata presence
- โ MIME type validation
- โ Container XML format
- โ Content OPF validation
- โ Spine and manifest integrity
- โ XHTML content validation
๐ Logging
All operations are logged with configurable verbosity. Logs are written to:
- Console output (with appropriate log levels)
logs/myepubapp.logfile (detailed operation logs)
๐ค Contributing
We welcome contributions! Please feel free to:
- Report bugs via GitHub Issues
- Submit feature requests
- Create pull requests with improvements
Development Setup
- Fork the repository
- Clone your fork:
git clone https://github.com/yourusername/myepubapp.git - Create a virtual environment:
python -m venv venv - Activate the environment:
source venv/bin/activate(Linux/Mac) orvenv\Scripts\activate(Windows) - Install development dependencies:
pip install -r requirements.txt - Install in development mode:
pip install -e . - Run tests:
python -m pytest
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Built with ebooklib for EPUB processing
- Uses Beautiful Soup for HTML parsing
- Inspired by the need for simple, reliable text-to-EPUB conversion tools
๐ Support
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Include sample input files and error messages when reporting bugs
๐ Changelog
Version 1.0.1 (2025-09-05)
- ๐ Fixed: EPUB TOC generation error when using h2/h3 chapter levels
- ๐ Fixed: Empty
<ol>elements in nav.xhtml causing epubcheck validation failures - ๐ง Improved: TOC generator now properly handles all chapter level combinations (h1, h2, h3)
- ๐ง Improved: Automatic level detection for chapters with skipped levels (e.g., intro โ h2)
- โ Enhanced: EPUB validation compliance for all supported chapter structures
Version 1.0.0 (2025-09-01)
- โจ Initial release with full text-to-EPUB conversion functionality
- ๐ Support for Chinese content with automatic title mark conversion
- ๐ Intelligent chapter detection using marker symbols
- ๐ Flexible operation modes (create new EPUB or append chapters)
- โ Built-in EPUB validation with detailed compliance checking
- ๐จ Cover image support
- ๐ Automatic table of contents generation
Version: 1.0.1 Author: Sam Weng Repository: https://github.com/eyes1971/myepubapp
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
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 myepubapp-1.0.1.tar.gz.
File metadata
- Download URL: myepubapp-1.0.1.tar.gz
- Upload date:
- Size: 24.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71e820950de848d32ae045a3a3005e2086c90ba6af6aef651fdbf4db965b8e21
|
|
| MD5 |
019663e05eecf0a683a71e33cccff3cf
|
|
| BLAKE2b-256 |
5f0e13490e8ed75d90384269da0560e5dbe690d139cc1bf1d078e6608f28d566
|
File details
Details for the file myepubapp-1.0.1-py3-none-any.whl.
File metadata
- Download URL: myepubapp-1.0.1-py3-none-any.whl
- Upload date:
- Size: 22.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68d4545408652a4a02ad93fecad25be0252b7e7013f4b42abd4922041d879889
|
|
| MD5 |
a319621c383df2c61906812b161b4ab1
|
|
| BLAKE2b-256 |
d644aae5f27435ff43a942f531e8adb854795c8fcf9baf9ed12b4b875bff334a
|