fix: 第 16 章补充零 import 与死配置两处核对事实;移除 subagent 临时脚本

This commit is contained in:
2026-10-20 21:57:31 +08:00
parent 64a60383e0
commit 2255ab0bcc
10 changed files with 17 additions and 48 deletions

View File

@@ -1,16 +0,0 @@
const fs = require('fs');
const h = fs.readFileSync('15-frontend.html', 'utf8');
let art = (h.match(/<article>([\s\S]*)<\/article>/) || [, ''])[1];
art = art.replace(/<pre[\s\S]*?<\/pre>/g, ' ')
.replace(/<nav class="pager">[\s\S]*?<\/nav>/g, ' ')
.replace(/<p class="foot">[\s\S]*?<\/p>/g, ' ')
.replace(/<p class="chapnav">[\s\S]*?<\/p>/g, ' ');
art = art.replace(/<[^>]+>/g, '').replace(/\s+/g, '');
let cjk = 0, ascii = 0, punct = 0, other = 0;
for (const ch of art) {
const c = ch.codePointAt(0);
if (c >= 0x4e00 && c <= 0x9fff) cjk++;
else if (c >= 0x20 && c <= 0x7e) ascii++;
else punct++;
}
console.log({ total: art.length, cjk, ascii, punct });

View File

@@ -1,17 +0,0 @@
const fs = require('fs');
const p = '15-frontend.html';
let h = fs.readFileSync(p, 'utf8');
// 1) 全文件:数字实体 -> 命名实体
h = h.replace(/&#x3C;/g, '&lt;').replace(/&#x3E;/g, '&gt;').replace(/&#x26;/g, '&amp;');
// 2) 代码块内:补齐 & 与 > 的转义(< 已全部处理)
h = h.replace(/<pre([^>]*)>([\s\S]*?)<\/pre>/g, (m, attrs, body) => {
let b = body;
b = b.replace(/&(?!(amp|lt|gt|quot|#\d+);)/g, '&amp;');
b = b.replace(/>/g, '&gt;');
return `<pre${attrs}>${b}</pre>`;
});
fs.writeFileSync(p, h);
console.log('done, bytes', h.length);