Converts Chinese-language novels from plain .txt files into EPUB e-books, detecting chapter boundaries automatically from the chapter headings in the text.
Novels distributed as plain text usually arrive as one large .txt file with no structure. The text is readable, but there is no table of contents, no way to jump between chapters, and no reasonable way to resume where you left off. This script finds the chapter headings, splits the text on them, and writes a proper EPUB with a navigable table of contents.
python [script name].py input.txtProduces input.epub in the same directory.
- Python 3
- [dependencies — e.g. ebooklib]
pip install -r requirements.txt[One or two sentences: what pattern the script looks for. For example — it scans for lines matching Chinese chapter headings such as 第一章 / 第1章 / 第一节, treats each match as a chapter boundary, and uses the matched line as the chapter title.]
- Written for Chinese-language novels; chapter detection assumes Chinese chapter headings and will not work on English or Japanese text as-is
- Input is assumed to be UTF-8
- No cover image or metadata editing — output is a plain, functional EPUB
[MIT, or whichever you prefer]