You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
1.2 KiB
23 lines
1.2 KiB
|
6 days ago
|
// 提取新增商机页需求批注区关键单元格的完整文本(解码实体)
|
||
|
|
import fs from 'node:fs';
|
||
|
|
|
||
|
|
const html = fs.readFileSync('e:/code/crm-backend-matt/.scratch/lanhu-latest/v29-customer-pages/a3-1-1-2-1_raw.html', 'utf8');
|
||
|
|
|
||
|
|
const decode = (s) => s
|
||
|
|
.replace(/&#x([0-9A-Fa-f]+);/g, (_, h) => String.fromCodePoint(parseInt(h, 16)))
|
||
|
|
.replace(/&#(\d+);/g, (_, d) => String.fromCodePoint(parseInt(d, 10)))
|
||
|
|
.replace(/ /g, ' ').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||
|
|
|
||
|
|
// 需求批注六个小节的内容单元格(新建商机皮肤)
|
||
|
|
const IDS = ['u654', 'u657', 'u665', 'u673', 'u681', 'u689'];
|
||
|
|
for (const id of IDS) {
|
||
|
|
// 匹配整个控件 div(含 _text 的嵌套 p),贪婪到该 div 结束前抓全部 <p>
|
||
|
|
const re = new RegExp(`<div id="${id}"[\\s\\S]*?id="${id}_text"[\\s\\S]*?</div>\\s*</div>`);
|
||
|
|
const m = html.match(re);
|
||
|
|
if (!m) { console.log(`\n### ${id}: NOT FOUND`); continue; }
|
||
|
|
const paras = (m[0].match(/<p><span[^>]*>[\s\S]*?<\/span><\/p>/g) || [])
|
||
|
|
.map(p => decode(p.replace(/<\/?p>/g, '').replace(/<\/?span[^>]*>/g, '')))
|
||
|
|
.join('\n');
|
||
|
|
console.log(`\n===== ${id} =====\n${paras}`);
|
||
|
|
}
|