fix(txt): recognize 番外/外传 chapter prefixes, closes #4016 (#4025)

Chinese novels commonly use 番外 (bonus), 番外篇, or 外传 as chapter
headings, optionally combined with 第N章. The previous regex only
matched 第N章 at line start, so lines like "番外 第1章 旗开得胜"
were dropped from the TOC. Treat 番外篇/番外/外传 as preface-style
keywords so they match alongside 楔子/前言/etc.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Huang Xin
2026-05-02 00:13:28 +08:00
committed by GitHub
parent 8ba052dc81
commit eadb355396
2 changed files with 39 additions and 1 deletions
+1 -1
View File
@@ -635,7 +635,7 @@ export class TxtToEpubConverter {
'(' +
[
String.raw`第[  零〇一二三四五六七八九十0-9][  零〇一二三四五六七八九十百千万0-9]*(?:[章卷节回讲篇封本册部话])(?:[::、  \(\)0-9]*[^\n-]{0,36})(?!\S)`,
String.raw`(?:楔子|前言|简介|引言|序言|序章|总论|概论|后记)(?:[:  ][^\n-]{0,36})?(?!\S)`,
String.raw`(?:楔子|前言|简介|引言|序言|序章|总论|概论|后记|番外篇|番外|外传)(?:[:  ][^\n-]{0,36})?(?!\S)`,
String.raw`chapter[\s.]*[0-9]+(?:[:.  ]+[^\n-]{0,50})?(?!\S)`,
].join('|') +
')',