// 提取新增商机页需求批注区关键单元格的完整文本(解码实体) 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 结束前抓全部

const re = new RegExp(`

\\s*
`); const m = html.match(re); if (!m) { console.log(`\n### ${id}: NOT FOUND`); continue; } const paras = (m[0].match(/

]*>[\s\S]*?<\/span><\/p>/g) || []) .map(p => decode(p.replace(/<\/?p>/g, '').replace(/<\/?span[^>]*>/g, ''))) .join('\n'); console.log(`\n===== ${id} =====\n${paras}`); }