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
- ๐ Intelligent Chapter Detection: Automatically identify and split chapters using special marker symbols
- ๐ฏ Smart Volume Detection: Automatic hierarchical TOC generation based on chapter level combinations
- Detects h1+h2 pattern and makes h1 chapters into volumes
- Detects h2+h3 pattern and makes h2 chapters into volumes
- Detects h1+h3 pattern and makes h1 chapters into volumes
- ๐ 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 with hierarchical structure
๐ 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.4 (2025-09-08)
- โจ Added Smart Volume Detection: Automatic hierarchical TOC generation based on chapter level combinations
- Detects h1+h2 pattern and makes h1 chapters into volumes
- Detects h2+h3 pattern and makes h2 chapters into volumes
- Detects h1+h3 pattern and makes h1 chapters into volumes
- ๐ฏ Added Intelligent TOC Structure: Creates nested table of contents for multi-volume books
- ๐ Enhanced Chapter Processing: Improved chapter ordering and Introduction page positioning
- ๐ Fixed Critical EPUB Generation Errors: Resolved multiple epubcheck validation failures
- Fixed duplicate cover image entries in manifest
- Fixed undefined cover property errors
- Fixed duplicate "cover" IDs causing OPF validation errors
- ๐ง Fixed TOC Reading Order Issues: Fixed NAV-011 warnings about TOC link order mismatch
- TOC links now match spine reading order
- Proper EPUB 3.0 compliance for navigation structure
- ๐ Fixed Cover Image Handling: Resolved cover image declaration and property issues
- Fixed RSC-008 error: Referenced resource not declared in OPF manifest
- Fixed OPF-027 error: Undefined property "cover"
- Fixed RSC-005 error: Duplicate entries in ZIP file
- ๐ Fixed Introduction Page Ordering: Fixed Introduction page appearing at the end instead of beginning
- Proper spine ordering: nav โ intro โ chapters
- Correct TOC positioning for introduction content
- โ Enhanced EPUB 3.0 Compliance: All generated EPUB files now pass epubcheck validation
Version 1.0.3 (2025-09-08)
- This update primarily focuses on optimizing the core
src/myepubapp/core/book.pymodule: - Updated function documentation:
_extract_chapters_from_epub()andmerge_existing_epub_with_new_chapters() - Updated log outputs: EPUB merge success and error messages
- Maintained functionality integrity: All changes are non-breaking, preserving all functional logic
Version 1.0.2 (2025-09-05)
- ๐ Fixed: Critical TOC generation bug causing missing chapters in table of contents
- ๐ Fixed: TOC only showing first few chapters, skipping subsequent ones in multi-chapter documents
- ๐ง Improved: TOC generator recursive logic now properly handles chapter indexing after processing child elements
- ๐ง Improved: Fixed index management in
build_toc_level()function to prevent chapter skipping - โ Enhanced: TOC generation now works correctly for any number of chapters and all hierarchy levels
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.4 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.4.tar.gz.
File metadata
- Download URL: myepubapp-1.0.4.tar.gz
- Upload date:
- Size: 27.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
091bc1133d3cc04a58b78f74fc54dfa489f3f762084766fcf8f7cee1b87ea0fd
|
|
| MD5 |
8a6a1a611f41739e4c7c231e82f261e1
|
|
| BLAKE2b-256 |
f457342a5419c86e5e792517f21382ac117864f4cdacb6d95f57eda05b959670
|
File details
Details for the file myepubapp-1.0.4-py3-none-any.whl.
File metadata
- Download URL: myepubapp-1.0.4-py3-none-any.whl
- Upload date:
- Size: 24.9 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 |
613792fc526832a0e2d2dad11e99c2c39659725ce851e0f380a560138f7cd95e
|
|
| MD5 |
c70bb65c1c160ef9a8b1af54ca045123
|
|
| BLAKE2b-256 |
25050e7286d42d586bc6b6aab2be75e11e7b50bba560bfc64f346c706e1a1a3c
|