Skip to main content

A powerful text-to-EPUB conversion tool

Project description

MyEPUBApp

PyPI version Python 3.8+ License: 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)

pip install myepubapp

Option 2: Install from Source

  1. Clone the repository:
git clone https://github.com/eyes1971/myepubapp.git
cd myepubapp
  1. Install dependencies:
pip install -r requirements.txt
  1. 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 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
  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 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

myepubapp-1.0.1.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

myepubapp-1.0.1-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

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

Hashes for myepubapp-1.0.1.tar.gz
Algorithm Hash digest
SHA256 71e820950de848d32ae045a3a3005e2086c90ba6af6aef651fdbf4db965b8e21
MD5 019663e05eecf0a683a71e33cccff3cf
BLAKE2b-256 5f0e13490e8ed75d90384269da0560e5dbe690d139cc1bf1d078e6608f28d566

See more details on using hashes here.

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

Hashes for myepubapp-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 68d4545408652a4a02ad93fecad25be0252b7e7013f4b42abd4922041d879889
MD5 a319621c383df2c61906812b161b4ab1
BLAKE2b-256 d644aae5f27435ff43a942f531e8adb854795c8fcf9baf9ed12b4b875bff334a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page