-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_parse.js
More file actions
55 lines (39 loc) · 1.34 KB
/
debug_parse.js
File metadata and controls
55 lines (39 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const body = `### 项目名称
测试
### 归属分类
📉 商业幻觉 (Market Fail) — 产品完美,但市场不需要
### 当初的幻觉 (Vision)
让AI自动套利赚钱
### 死亡原因 (Cause of Death)
根本不赚钱
### 技术栈
nodejs
### 项目链接(可选)
https://github.com/codetodamoon/arbitrage-monitor
### 墓志铭(可选)
什么时候能赚钱`;
const FIELD_LABELS = {
'项目名称': 'projectName',
'归属分类': 'category',
'当初的幻觉 (Vision)': 'vision',
'死亡原因 (Cause of Death)': 'deathCause',
'技术栈': 'techStack',
'项目链接(可选)': 'projectLink',
'墓志铭(可选)': 'epitaph',
};
console.log('=== Split 结果 ===');
const sections = body.split(/(?=^###\s)/m);
sections.forEach((s, i) => console.log(`[${i}] len=${s.length} start=${s.slice(0,50).replace(/\n/g,'↵')}`));
console.log('\n=== 解析结果 ===');
const fields = {};
for (const section of sections) {
const match = section.match(/^###\s+(.+?)\n+([\s\S]*?)(?=\n###|\n*$)/);
if (!match) { console.log('NO MATCH:', section.slice(0,50)); continue; }
const label = match[1].trim();
const value = match[2].trim();
if (FIELD_LABELS[label] !== undefined && value) {
fields[FIELD_LABELS[label]] = value;
}
console.log('OK:', label, '->', value.slice(0,30));
}
console.log('\n最终字段:', fields);