Skip to main content

txt2epub-next

English | 中文

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:

python -m pip install txt2epub-next

For local development, install an editable checkout instead:

python -m pip install -e .

Convert a book

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

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

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:

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 &. 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:

python -m pip install ruff
make check

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

python scripts\check_txt_compatibility.py tests

Publishing

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

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

Upload the validated artifacts to PyPI with an API token:

python -m twine upload dist/*

License

This project is released under the MIT License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

txt2epub_next-1.0.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

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

txt2epub_next-1.0.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file txt2epub_next-1.0.0.tar.gz.

File metadata

  • Download URL: txt2epub_next-1.0.0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for txt2epub_next-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f8a21856d7bc850c8a4581dc650eed85cd9a42d780569d08b51a9aa69cc3b3fb
MD5 d63ed18724ce7cf451abec67a9f2778b
BLAKE2b-256 edb1a0c4e5fe1ad3dd50d78036dc99658400ae43f7c7560e2fe139fef165444c

See more details on using hashes here.

Provenance

The following attestation bundles were made for txt2epub_next-1.0.0.tar.gz:

Publisher: publish.yml on hehetoshang/txt2epub-next

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file txt2epub_next-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: txt2epub_next-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for txt2epub_next-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4da27b44dc2bc47ad4bde6d6dfff0673fa8e449e92169863acd2a036d3b67650
MD5 2a9dfe0ad3625562fd7cd1959669c2ff
BLAKE2b-256 9fa53aa657745bbed2dfe25a61b3b1978f0a6ecdf83b5f86a7fd0bf421fcb7dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for txt2epub_next-1.0.0-py3-none-any.whl:

Publisher: publish.yml on hehetoshang/txt2epub-next

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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