fix: 第 16 章补充零 import 与死配置两处核对事实;移除 subagent 临时脚本
This commit is contained in:
@@ -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 });
|
||||
@@ -1,17 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const p = '15-frontend.html';
|
||||
let h = fs.readFileSync(p, 'utf8');
|
||||
|
||||
// 1) 全文件:数字实体 -> 命名实体
|
||||
h = h.replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&');
|
||||
|
||||
// 2) 代码块内:补齐 & 与 > 的转义(< 已全部处理)
|
||||
h = h.replace(/<pre([^>]*)>([\s\S]*?)<\/pre>/g, (m, attrs, body) => {
|
||||
let b = body;
|
||||
b = b.replace(/&(?!(amp|lt|gt|quot|#\d+);)/g, '&');
|
||||
b = b.replace(/>/g, '>');
|
||||
return `<pre${attrs}>${b}</pre>`;
|
||||
});
|
||||
|
||||
fs.writeFileSync(p, h);
|
||||
console.log('done, bytes', h.length);
|
||||
Reference in New Issue
Block a user