网页适配第二部多章:正则支持第N章(中文/阿拉伯数字)+ CHAPTERS 加第二部 Ch2 条目

- renderNovel 第二部正则从'第一章'写死改为'第.+?章'通用捕获,映射中文数字→01/02...
- CHAPTERS 新增 n=-2 第 23 条(第二部 Ch2)
- renderChapterList 负 n 值支持'II·01 / II·02'编号

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
kang
2026-04-18 14:18:26 +08:00
parent 368fcfa577
commit 64b80f1f5f
2 changed files with 15 additions and 5 deletions

View File

@@ -328,6 +328,13 @@
"message": "auto-save 2026-04-18 14:13 (~1)", "message": "auto-save 2026-04-18 14:13 (~1)",
"hash": "b71ec7e", "hash": "b71ec7e",
"files_changed": 1 "files_changed": 1
},
{
"ts": "2026-04-18T14:17:40+08:00",
"type": "commit",
"message": "第二部 · 第二章《他差一点把那些刺长回来》(+3800 字)",
"hash": "368fcfa",
"files_changed": 3
} }
] ]
} }

View File

@@ -833,6 +833,7 @@ const CHAPTERS = [
{ file: 'extra/s2_blank_second_page.jpg', cap: '我 怕 的——', sub: '第二部 · 序章 · 留白' } { file: 'extra/s2_blank_second_page.jpg', cap: '我 怕 的——', sub: '第二部 · 序章 · 留白' }
] }, ] },
{ n: -1, title: '另一个看见了的人', img: 'extra/s2_blank_second_page.jpg', volume: '第二部 · 起笔', hint: '沈陌登门:顾先生,我写到这里,就等您告诉我,下面该不该写下去' }, { n: -1, title: '另一个看见了的人', img: 'extra/s2_blank_second_page.jpg', volume: '第二部 · 起笔', hint: '沈陌登门:顾先生,我写到这里,就等您告诉我,下面该不该写下去' },
{ n: -2, title: '他差一点把那些刺长回来', img: null, volume: '第二部 · 起笔', hint: '三天读尽白皮书,差一点对一个系统动了信任测试的念头;出门去见了韩锐' },
]; ];
function renderChapterList() { function renderChapterList() {
@@ -845,7 +846,7 @@ function renderChapterList() {
} }
let num; let num;
if (ch.n === 0) num = '终'; if (ch.n === 0) num = '终';
else if (ch.n === -1) num = 'II'; else if (ch.n < 0) num = 'II·' + String(-ch.n).padStart(2, '0');
else num = ch.n.toString().padStart(2, '0'); else num = ch.n.toString().padStart(2, '0');
const title = ch.n === 0 ? ch.title.replace('终章 · ', '') : ch.title; const title = ch.n === 0 ? ch.title.replace('终章 · ', '') : ch.title;
html += ` html += `
@@ -944,12 +945,14 @@ function renderNovel(md) {
// kicker assigned below // kicker assigned below
var kicker = isEpilogue ? 'EPILOGUE' : 'CHAPTER ' + num; var kicker = isEpilogue ? 'EPILOGUE' : 'CHAPTER ' + num;
} else { } else {
const m2 = heading.match(/^第二部\s*·\s*第章\s*·\s*(.+)$/); const m2 = heading.match(/^第二部\s*·\s*第(.+?)章\s*·\s*(.+)$/);
if (!m2) return; if (!m2) return;
isPart2 = true; isPart2 = true;
num = 'II · 01'; const cnMap = { '一': '01', '二': '02', '三': '03', '四': '04', '五': '05', '六': '06', '七': '07', '八': '08', '九': '09', '十': '10' };
title = m2[1]; const arabic = cnMap[m2[1]] || m2[1];
var kicker = 'PART II · CHAPTER 01'; num = 'II · ' + arabic;
title = m2[2];
var kicker = 'PART II · CHAPTER ' + arabic;
} }
const ch = CHAPTERS[idx]; const ch = CHAPTERS[idx];
const imgPath = ch ? `./images/${ch.img}` : ''; const imgPath = ch ? `./images/${ch.img}` : '';