# MyEPUBApp
[](https://pypi.org/project/myepubapp/)
[](https://www.python.org/downloads/)
[](https://opensource.org/licenses/MIT)
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)
```bash
pip install myepubapp
```
### Option 2: Install from Source
1. Clone the repository:
```bash
git clone https://github.com/eyes1971/myepubapp.git
cd myepubapp
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Install in development mode:
```bash
pip install -e .
```
## ๐ Usage
### Basic Usage
#### 1. Create New EPUB File
```bash
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
```bash
myepubapp -a input.txt --input-epub existing.epub --output-epub updated.epub
```
#### 3. Validate EPUB File
```bash
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
```bash
myepubapp -i sample.txt --output-epub mybook.epub
```
### Create EPUB with Chinese Tag Conversion
```bash
myepubapp -i sample.txt --output-epub mybook.epub --convert-tags
```
### Add Cover Image
```bash
myepubapp -i sample.txt --output-epub mybook.epub --cover cover.jpg
```
### Append Chapters to Existing EPUB
```bash
myepubapp -a chapter2.txt --input-epub mybook.epub --output-epub mybook_updated.epub
```
### Validate EPUB File
```bash
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 manipulation
- `beautifulsoup4>=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.log` file (detailed operation logs)
## ๐ค Contributing
We welcome contributions! Please feel free to:
1. Report bugs via [GitHub Issues](https://github.com/eyes1971/myepubapp/issues)
2. Submit feature requests
3. Create pull requests with improvements
### Development Setup
1. Fork the repository
2. Clone your fork: `git clone https://github.com/yourusername/myepubapp.git`
3. Create a virtual environment: `python -m venv venv`
4. Activate the environment: `source venv/bin/activate` (Linux/Mac) or `venv\Scripts\activate` (Windows)
5. Install development dependencies: `pip install -r requirements.txt`
6. Install in development mode: `pip install -e .`
7. Run tests: `python -m pytest`
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## ๐ Acknowledgments
- Built with [ebooklib](https://github.com/aerkalov/ebooklib) for EPUB processing
- Uses [Beautiful Soup](https://www.crummy.com/software/BeautifulSoup/) 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](https://github.com/eyes1971/myepubapp/issues) page
- Create a new issue with detailed information
- Include sample input files and error messages when reporting bugs
## ๐ Changelog
### Version 1.0.3 (2025-09-08)
- ๐ **Internationalization**: Replaced Chinese comments with English comments in source code for better maintainability and global collaboration
- ๐งน **Cleanup**: Cleaned up project directory by removing unused temporary files and test artifacts
- ๐ **Documentation**: Added comprehensive CHANGELOG.md file for better version tracking
- ๐ง **Maintenance**: Removed temporary directories (`temp_epub/`, `temp_final/`, `temp_original/`) and test files for cleaner repository
### 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.3
**Author**: Sam Weng
**Repository**: [https://github.com/eyes1971/myepubapp](https://github.com/eyes1971/myepubapp)
Raw data
{
"_id": null,
"home_page": null,
"name": "myepubapp",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Sam Weng <eyes1971@gmail.com>",
"keywords": "epub, text-processing, ebook, converter",
"author": null,
"author_email": "Sam Weng <eyes1971@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/5c/9d/0a3515a27843a6832cc06fcfa5e392c5e8d9b0ce4550f4344fc6fd71393b/myepubapp-1.0.3.tar.gz",
"platform": null,
"description": "# MyEPUBApp\n\n[](https://pypi.org/project/myepubapp/)\n[](https://www.python.org/downloads/)\n[](https://opensource.org/licenses/MIT)\n\nA 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.\n\n## \u2728 Features\n\n- \ud83d\udcd6 **Text to EPUB Conversion**: Convert plain text files to fully EPUB-compliant e-books\n- \ud83c\udf0f **Chinese Content Support**: Specially optimized for Chinese content with automatic Chinese book title mark conversion\n- \ud83d\udcd1 **Intelligent Chapter Detection**: Automatically identify and split chapters using special marker symbols\n- \ud83d\udd04 **Flexible Operation Modes**: Support for creating new EPUB files or appending chapters to existing ones\n- \u2705 **EPUB Validation**: Built-in EPUB format validation with detailed compliance checking\n- \ud83c\udfd7\ufe0f **Modular Architecture**: Clean, maintainable code structure for easy extension\n- \ud83d\udcdd **Comprehensive Logging**: Detailed operation logging with configurable log levels\n- \ud83c\udfa8 **Cover Image Support**: Add custom cover images to your EPUB files\n- \ud83d\udccb **Table of Contents**: Automatic generation of navigation and table of contents\n\n## \ud83d\ude80 Installation\n\n### Requirements\n- Python 3.8 or higher\n- pip package manager\n\n### Option 1: Install from PyPI (Recommended)\n\n```bash\npip install myepubapp\n```\n\n### Option 2: Install from Source\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/eyes1971/myepubapp.git\ncd myepubapp\n```\n\n2. Install dependencies:\n```bash\npip install -r requirements.txt\n```\n\n3. Install in development mode:\n```bash\npip install -e .\n```\n\n## \ud83d\udcd6 Usage\n\n### Basic Usage\n\n#### 1. Create New EPUB File\n```bash\nmyepubapp -i input.txt --output-epub output.epub\n```\n\n**Automatic Title Generation**: Book titles are automatically generated from input filenames (e.g., `my_book.txt` becomes \"My Book\")\n\n#### 2. Append Chapters to Existing EPUB\n```bash\nmyepubapp -a input.txt --input-epub existing.epub --output-epub updated.epub\n```\n\n#### 3. Validate EPUB File\n```bash\nmyepubapp -v --input-epub file.epub\n```\n\n### Command Line Options\n\n| Option | Short | Description |\n|--------|-------|-------------|\n| `--init` | `-i` | Initialize mode: create new EPUB file |\n| `--append` | `-a` | Append mode: add chapters to existing EPUB |\n| `--validate` | `-v` | Validate EPUB file format and structure |\n| `input_file` | | Input text file path (not required for validate mode) |\n| `--input-epub` | `-ie` | Existing EPUB file (required for append/validate modes) |\n| `--output-epub` | `-o` | Output EPUB file path |\n| `--convert-tags` | `-ct` | Convert `<>` tags to Chinese book title marks `\u300a\u300b` |\n| `--cover` | `-c` | Path to cover image file |\n\n### Input File Format\n\nText files should use special marker symbols for chapter organization:\n\n```\n\u203b\u2606 Introduction Title\nThis is the introduction content.\nIt can span multiple paragraphs and will be displayed as a separate introduction page.\n\n\u203b\u2170 Chapter 1 Title\nChapter content goes here...\nMultiple paragraphs are supported.\n\n\u203b\u2171 Chapter 1 Section 1\nSubsection content...\n\n\u203b\u2172 Chapter 1 Section 1 Subsection 1\nDeeper level content with full formatting support.\n```\n\n#### Marker Symbols:\n- `\u203b\u2606`: Introduction page (creates separate intro page)\n- `\u203b\u2170`: Level 1 chapter (h1 heading)\n- `\u203b\u2171`: Level 2 chapter (h2 heading)\n- `\u203b\u2172`: Level 3 chapter (h3 heading)\n\n## \ud83d\udccb Examples\n\n### Create Simple EPUB\n```bash\nmyepubapp -i sample.txt --output-epub mybook.epub\n```\n\n### Create EPUB with Chinese Tag Conversion\n```bash\nmyepubapp -i sample.txt --output-epub mybook.epub --convert-tags\n```\n\n### Add Cover Image\n```bash\nmyepubapp -i sample.txt --output-epub mybook.epub --cover cover.jpg\n```\n\n### Append Chapters to Existing EPUB\n```bash\nmyepubapp -a chapter2.txt --input-epub mybook.epub --output-epub mybook_updated.epub\n```\n\n### Validate EPUB File\n```bash\nmyepubapp -v --input-epub mybook.epub\n```\n\n## \ud83c\udfd7\ufe0f Project Structure\n\n```\nmyepubapp/\n\u251c\u2500\u2500 core/ # Core business logic\n\u2502 \u251c\u2500\u2500 __init__.py\n\u2502 \u251c\u2500\u2500 book.py # EPUB book management\n\u2502 \u251c\u2500\u2500 chapter.py # Chapter data structures\n\u2502 \u2514\u2500\u2500 metadata.py # EPUB metadata handling\n\u251c\u2500\u2500 generators/ # Content generation modules\n\u2502 \u251c\u2500\u2500 __init__.py\n\u2502 \u251c\u2500\u2500 content.py # Content processing and chapter generation\n\u2502 \u2514\u2500\u2500 toc.py # Table of contents generation\n\u251c\u2500\u2500 utils/ # Utility modules\n\u2502 \u251c\u2500\u2500 __init__.py\n\u2502 \u251c\u2500\u2500 epub_validator.py # EPUB format validation\n\u2502 \u251c\u2500\u2500 file_handler.py # File I/O operations\n\u2502 \u251c\u2500\u2500 logger.py # Logging configuration\n\u2502 \u2514\u2500\u2500 text_processor.py # Text processing utilities\n\u251c\u2500\u2500 exceptions/ # Custom exception classes\n\u2502 \u251c\u2500\u2500 __init__.py\n\u2502 \u2514\u2500\u2500 epub_exceptions.py # EPUB-specific exceptions\n\u251c\u2500\u2500 cli.py # Command-line interface\n\u251c\u2500\u2500 __init__.py # Package initialization\n\u2514\u2500\u2500 py.typed # Type hints marker\n```\n\n## \ud83d\udccb Dependencies\n\n- `ebooklib>=0.18.0`: Core EPUB file processing and manipulation\n- `beautifulsoup4>=4.12.0`: HTML/XML parsing and manipulation\n\n## \ud83d\udd0d Validation Features\n\nThe built-in EPUB validator checks:\n- \u2705 File structure compliance\n- \u2705 Required metadata presence\n- \u2705 MIME type validation\n- \u2705 Container XML format\n- \u2705 Content OPF validation\n- \u2705 Spine and manifest integrity\n- \u2705 XHTML content validation\n\n## \ud83d\udcdd Logging\n\nAll operations are logged with configurable verbosity. Logs are written to:\n- Console output (with appropriate log levels)\n- `logs/myepubapp.log` file (detailed operation logs)\n\n## \ud83e\udd1d Contributing\n\nWe welcome contributions! Please feel free to:\n\n1. Report bugs via [GitHub Issues](https://github.com/eyes1971/myepubapp/issues)\n2. Submit feature requests\n3. Create pull requests with improvements\n\n### Development Setup\n\n1. Fork the repository\n2. Clone your fork: `git clone https://github.com/yourusername/myepubapp.git`\n3. Create a virtual environment: `python -m venv venv`\n4. Activate the environment: `source venv/bin/activate` (Linux/Mac) or `venv\\Scripts\\activate` (Windows)\n5. Install development dependencies: `pip install -r requirements.txt`\n6. Install in development mode: `pip install -e .`\n7. Run tests: `python -m pytest`\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## \ud83d\ude4f Acknowledgments\n\n- Built with [ebooklib](https://github.com/aerkalov/ebooklib) for EPUB processing\n- Uses [Beautiful Soup](https://www.crummy.com/software/BeautifulSoup/) for HTML parsing\n- Inspired by the need for simple, reliable text-to-EPUB conversion tools\n\n## \ud83d\udcde Support\n\nIf you encounter any issues or have questions:\n\n- Check the [Issues](https://github.com/eyes1971/myepubapp/issues) page\n- Create a new issue with detailed information\n- Include sample input files and error messages when reporting bugs\n\n## \ud83d\udccb Changelog\n\n### Version 1.0.3 (2025-09-08)\n- \ud83c\udf10 **Internationalization**: Replaced Chinese comments with English comments in source code for better maintainability and global collaboration\n- \ud83e\uddf9 **Cleanup**: Cleaned up project directory by removing unused temporary files and test artifacts\n- \ud83d\udcdd **Documentation**: Added comprehensive CHANGELOG.md file for better version tracking\n- \ud83d\udd27 **Maintenance**: Removed temporary directories (`temp_epub/`, `temp_final/`, `temp_original/`) and test files for cleaner repository\n\n### Version 1.0.2 (2025-09-05)\n- \ud83d\udc1b **Fixed**: Critical TOC generation bug causing missing chapters in table of contents\n- \ud83d\udc1b **Fixed**: TOC only showing first few chapters, skipping subsequent ones in multi-chapter documents\n- \ud83d\udd27 **Improved**: TOC generator recursive logic now properly handles chapter indexing after processing child elements\n- \ud83d\udd27 **Improved**: Fixed index management in `build_toc_level()` function to prevent chapter skipping\n- \u2705 **Enhanced**: TOC generation now works correctly for any number of chapters and all hierarchy levels\n\n### Version 1.0.1 (2025-09-05)\n- \ud83d\udc1b **Fixed**: EPUB TOC generation error when using h2/h3 chapter levels\n- \ufffd **Fixed**: Empty `<ol>` elements in nav.xhtml causing epubcheck validation failures\n- \ud83d\udd27 **Improved**: TOC generator now properly handles all chapter level combinations (h1, h2, h3)\n- \ud83d\udd27 **Improved**: Automatic level detection for chapters with skipped levels (e.g., intro \u2192 h2)\n- \u2705 **Enhanced**: EPUB validation compliance for all supported chapter structures\n\n### Version 1.0.0 (2025-09-01)\n- \u2728 Initial release with full text-to-EPUB conversion functionality\n- \ufffd\ud83d\udcd6 Support for Chinese content with automatic title mark conversion\n- \ud83d\udcd1 Intelligent chapter detection using marker symbols\n- \ud83d\udd04 Flexible operation modes (create new EPUB or append chapters)\n- \u2705 Built-in EPUB validation with detailed compliance checking\n- \ud83c\udfa8 Cover image support\n- \ud83d\udccb Automatic table of contents generation\n\n---\n\n**Version**: 1.0.3\n**Author**: Sam Weng\n**Repository**: [https://github.com/eyes1971/myepubapp](https://github.com/eyes1971/myepubapp)\n",
"bugtrack_url": null,
"license": null,
"summary": "A powerful text-to-EPUB conversion tool",
"version": "1.0.3",
"project_urls": {
"Changelog": "https://github.com/eyes1971/myepubapp/blob/main/CHANGELOG.md",
"Homepage": "https://github.com/eyes1971/myepubapp",
"Issues": "https://github.com/eyes1971/myepubapp/issues",
"Repository": "https://github.com/eyes1971/myepubapp"
},
"split_keywords": [
"epub",
" text-processing",
" ebook",
" converter"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ed50a5107d64cfa9e5ee0c774a4260b0da6fd07f10950639a09fe48497199b22",
"md5": "e1eadef843a485193f056874abb6589b",
"sha256": "925f0376e1dfde77493917c8f2aabe84725d0f206e49c1ac0e4d468284a8d154"
},
"downloads": -1,
"filename": "myepubapp-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e1eadef843a485193f056874abb6589b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 24002,
"upload_time": "2025-09-08T03:49:21",
"upload_time_iso_8601": "2025-09-08T03:49:21.463304Z",
"url": "https://files.pythonhosted.org/packages/ed/50/a5107d64cfa9e5ee0c774a4260b0da6fd07f10950639a09fe48497199b22/myepubapp-1.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "5c9d0a3515a27843a6832cc06fcfa5e392c5e8d9b0ce4550f4344fc6fd71393b",
"md5": "a2879e33cbcb3fdf0fec7b94c4f54eec",
"sha256": "03ef17220aa50168ff5ee56f3e0f1b91e8c5970a2b1d735695a7181bddc9b2e1"
},
"downloads": -1,
"filename": "myepubapp-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "a2879e33cbcb3fdf0fec7b94c4f54eec",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 26566,
"upload_time": "2025-09-08T03:49:22",
"upload_time_iso_8601": "2025-09-08T03:49:22.676527Z",
"url": "https://files.pythonhosted.org/packages/5c/9d/0a3515a27843a6832cc06fcfa5e392c5e8d9b0ce4550f4344fc6fd71393b/myepubapp-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-08 03:49:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "eyes1971",
"github_project": "myepubapp",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "ebooklib",
"specs": [
[
">=",
"0.18.0"
]
]
},
{
"name": "beautifulsoup4",
"specs": [
[
">=",
"4.12.0"
]
]
}
],
"lcname": "myepubapp"
}