Metadata-Version: 2.4
Name: txt2epub-next
Version: 1.0.0
Summary: A simple TXT to EPUB converter
Project-URL: Homepage, https://github.com/hehetoshang/txt2epub-next
Project-URL: Source, https://github.com/hehetoshang/txt2epub-next
Project-URL: Issues, https://github.com/hehetoshang/txt2epub-next/issues
License: MIT License
        
        Copyright (c) 2026 houheya
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: ebook,epub,txt
Classifier: Environment :: Console
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Text Processing
Requires-Python: >=3.10
Requires-Dist: charset-normalizer>=3.3.0
Requires-Dist: ebooklib>=0.18
Requires-Dist: langdetect>=1.0.0
Requires-Dist: pillow>=10.4.0
Description-Content-Type: text/markdown

# txt2epub-next

[English](README.md) | [中文](README.zh.md)

`txt2epub-next` is a command-line converter for turning TXT novels and other long-form text into EPUB books. It is designed for common Chinese TXT sources as well as English chapter headings, and has no GUI dependency.

## Requirements

- Python 3.10 or newer

## Install

Install the published package and its command-line entry point:

```powershell
python -m pip install txt2epub-next
```

For local development, install an editable checkout instead:

```powershell
python -m pip install -e .
```

## Convert a book

```powershell
txt2epub-next convert --input .\novel.txt
```

The EPUB is written beside the input file by default. Set its metadata or destination when needed:

```powershell
txt2epub-next convert `
  --input .\novel.txt `
  --output .\novel.epub `
  --title "My Novel" `
  --author "Author" `
  --language zh `
  --cover .\cover.png
```

For safety, an existing output file is not replaced unless `--overwrite` is supplied. The output path may not be the input path. The Python API follows the same rule and requires `overwrite=True` for an existing destination.

Wrapped prose is reflowed within each paragraph for comfortable reading at different font sizes. Use `--preserve-line-breaks` for poetry or preformatted text where every source line break matters.

When a cover is supplied, it is the first page. It is followed by a title page with the title, author, character count, and chapter count. Neither front page is listed as a table-of-contents entry.

If a TXT header contains fields such as `书名：`, `作者：`, and `简介：`, they are used automatically. For other sources, pass `--description "..."` or `--description-file .\description.txt` to add a description to the title page and EPUB metadata.

After installing an editable checkout, the module can also be run with:

```powershell
python -m txt2epub_next convert --input .\novel.txt
```

Run `txt2epub-next convert --help` for the complete option list. `--encoding` can force a known input encoding; otherwise the converter tries UTF-8, GB18030, GBK, and automatic detection.

## Chapter recognition

The converter recognises common chapter forms, including:

- Chinese headings such as `第一章 标题`, `第二回 标题`, `第 十二 章 标题`, and `012 标题`.
- Volume headings such as `第一卷 标题` and `【第一卷：标题】`.
- Numbered headings such as `001 [标题]` and `1. Title`.
- English `Chapter`, `Book`, `Part`, and `Volume` headings.
- Special sections such as `序章`, `楔子`, `前言`, `终章`, `尾声`, `后记`, `附录`, and `番外`.

It also removes repeated title-only tables of contents, converts common scraped HTML paragraph tags, and decodes HTML entities such as `&amp;`. Decimal numbers and timestamps are deliberately not treated as chapter headings.

If no reliable chapter layout is found, the source is kept as one EPUB chapter instead of splitting ordinary paragraphs incorrectly.

## Development checks

Install the development tool and run the available checks:

```powershell
python -m pip install ruff
make check
```

To scan TXT sources for HTML markup, entities, replacement characters, and invalid XML control characters:

```powershell
python scripts\check_txt_compatibility.py tests
```

## Publishing

Build a source distribution and wheel, then validate the package metadata:

```powershell
python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*
```

Upload the validated artifacts to [PyPI](https://pypi.org/) with an API token:

```powershell
python -m twine upload dist/*
```

## License

This project is released under the [MIT License](LICENSE).
