nx-json-parser 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parser.d.ts +2 -0
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +92 -13
- package/dist/parser.js.map +1 -1
- package/dist/plugins/detect-bullet-mode.d.ts.map +1 -1
- package/dist/plugins/detect-bullet-mode.js +8 -5
- package/dist/plugins/detect-bullet-mode.js.map +1 -1
- package/package.json +1 -1
- package/src/parser.ts +103 -14
- package/src/plugins/detect-bullet-mode.ts +146 -143
- package/test/parser.2.test.ts +12 -12
package/dist/parser.d.ts
CHANGED
package/dist/parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAc,aAAa,EAAE,MAAM,YAAY,CAAC;AAIxE,qBAAa,YAAY;IACrB,OAAO,CAAC,SAAS,CAEG;IAEpB,OAAO,CAAC,OAAO,CAA0B;gBAE7B,OAAO,GAAE,aAAkB;IAOvC,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,EAAE;
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAc,aAAa,EAAE,MAAM,YAAY,CAAC;AAIxE,qBAAa,YAAY;IACrB,OAAO,CAAC,SAAS,CAEG;IAEpB,OAAO,CAAC,OAAO,CAA0B;gBAE7B,OAAO,GAAE,aAAkB;IAOvC,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,EAAE;IAuI1C;;OAEG;IACH,OAAO,CAAC,cAAc;IA+BtB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAuE9B;;OAEG;IACH,OAAO,CAAC,WAAW;IAQnB;;OAEG;IACH,OAAO,CAAC,YAAY;IAoBpB;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAWlE,OAAO,CAAC,mBAAmB;IAqB3B,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,oBAAoB;CAiC/B"}
|
package/dist/parser.js
CHANGED
|
@@ -49,7 +49,7 @@ export class RemarkParser {
|
|
|
49
49
|
};
|
|
50
50
|
currentNodes = [];
|
|
51
51
|
}
|
|
52
|
-
else if (node.type === 'list' && bulletMode === BulletMode.SECTIONS) {
|
|
52
|
+
else if (node.type === 'list' && !node.ordered && bulletMode === BulletMode.SECTIONS) {
|
|
53
53
|
// Bullet-style sections mode: each root-level bullet is a section
|
|
54
54
|
if (currentSection) {
|
|
55
55
|
this.mergeAndPushSection(sections, currentSection, currentNodes, bulletMode);
|
|
@@ -58,17 +58,64 @@ export class RemarkParser {
|
|
|
58
58
|
}
|
|
59
59
|
// Process each list item as a section
|
|
60
60
|
const newSections = [];
|
|
61
|
+
// If we have a current section pending content, and this list is just text items, maybe it belongs to currentSection?
|
|
62
|
+
// But detect-bullet-mode says SECTIONS. So we expect sections.
|
|
61
63
|
for (const listItem of node.children) {
|
|
62
64
|
newSections.push(...this.processBulletAsSection(listItem));
|
|
63
65
|
}
|
|
64
66
|
if (newSections.length > 0) {
|
|
67
|
+
// Refined Sibling Logic:
|
|
68
|
+
// If a section has empty content, and is followed by sections that look like simple items...
|
|
69
|
+
// But processBulletAsSection transforms every item into a section.
|
|
70
|
+
// We need to merge them if they are actually content.
|
|
71
|
+
// Post-processing merge:
|
|
72
|
+
const mergedSections = [];
|
|
73
|
+
let activeSection = null;
|
|
74
|
+
for (const sec of newSections) {
|
|
75
|
+
// Heuristic: Is this really a section or just an item?
|
|
76
|
+
// If detect-bullet-mode said SECTIONS, usually we trust it.
|
|
77
|
+
// But for mixed lists: "- Assumptions" (sec) "- Item 1" (sec?) "- Item 2" (sec?)
|
|
78
|
+
// Check if 'sec' looks like a property or a value.
|
|
79
|
+
// Ideally strictly, everything is a property.
|
|
80
|
+
// But in the test case "- Assumptions \n - Val 1 \n - Val 2",
|
|
81
|
+
// they are siblings.
|
|
82
|
+
if (activeSection && this.shouldMergeAsContent(activeSection, sec)) {
|
|
83
|
+
// Merge content
|
|
84
|
+
if (!activeSection.content) {
|
|
85
|
+
activeSection.content = [sec.heading]; // Use heading as value
|
|
86
|
+
}
|
|
87
|
+
else if (Array.isArray(activeSection.content)) {
|
|
88
|
+
activeSection.content.push(sec.heading);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// Convert existing string content to array? Or mix?
|
|
92
|
+
activeSection.content = [activeSection.content, sec.heading];
|
|
93
|
+
}
|
|
94
|
+
// APPEND any content of sec as well?
|
|
95
|
+
if (sec.content) {
|
|
96
|
+
if (Array.isArray(sec.content)) {
|
|
97
|
+
activeSection.content.push(...sec.content);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
activeSection.content.push(sec.content);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
activeSection = sec;
|
|
106
|
+
mergedSections.push(sec);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
65
109
|
// Push all except the last one as complete sections
|
|
66
|
-
|
|
67
|
-
|
|
110
|
+
if (mergedSections.length > 0) {
|
|
111
|
+
for (let i = 0; i < mergedSections.length - 1; i++) {
|
|
112
|
+
sections.push(mergedSections[i]);
|
|
113
|
+
}
|
|
114
|
+
// Keep the last one as currentSection to capture subsequent loose content
|
|
115
|
+
currentSection = mergedSections[mergedSections.length - 1];
|
|
68
116
|
}
|
|
69
|
-
// Keep the last one as currentSection to capture subsequent loose content
|
|
70
|
-
currentSection = newSections[newSections.length - 1];
|
|
71
117
|
}
|
|
118
|
+
// Original simple loop removed in favor of refined logic above
|
|
72
119
|
}
|
|
73
120
|
else {
|
|
74
121
|
currentNodes.push(node);
|
|
@@ -170,9 +217,9 @@ export class RemarkParser {
|
|
|
170
217
|
};
|
|
171
218
|
}
|
|
172
219
|
else {
|
|
173
|
-
//
|
|
220
|
+
// Flatten all other children into text
|
|
174
221
|
const nodeText = contentNodes
|
|
175
|
-
.map((node) =>
|
|
222
|
+
.map((node) => this.nodeToString(node))
|
|
176
223
|
.join('\n\n')
|
|
177
224
|
.trim();
|
|
178
225
|
content = sameNodeContent ? sameNodeContent + '\n\n' + nodeText : nodeText;
|
|
@@ -227,12 +274,7 @@ export class RemarkParser {
|
|
|
227
274
|
return result;
|
|
228
275
|
}
|
|
229
276
|
mergeAndPushSection(sections, section, nodes, bulletMode) {
|
|
230
|
-
//
|
|
231
|
-
// we shouldn't push it again?
|
|
232
|
-
// Wait, my logic implementation in loop:
|
|
233
|
-
// "newSections.push(...); if (newSections.length > 0) { ... loop push n-1 ... currentSection = nth }"
|
|
234
|
-
// So currentSection is NOT in sections yet.
|
|
235
|
-
// It's safe to push.
|
|
277
|
+
// ... (existing implementation)
|
|
236
278
|
const newContent = this.processContent(nodes, bulletMode);
|
|
237
279
|
if (newContent) {
|
|
238
280
|
if (!section.content) {
|
|
@@ -252,5 +294,42 @@ export class RemarkParser {
|
|
|
252
294
|
}
|
|
253
295
|
sections.push(section);
|
|
254
296
|
}
|
|
297
|
+
nodeToString(node) {
|
|
298
|
+
if (node.type === 'table') {
|
|
299
|
+
return JSON.stringify(this.tableToArray(node));
|
|
300
|
+
}
|
|
301
|
+
if (node.type === 'list') {
|
|
302
|
+
return this.listToArray(node).map(item => `- ${item}`).join('\n');
|
|
303
|
+
}
|
|
304
|
+
return toString(node);
|
|
305
|
+
}
|
|
306
|
+
shouldMergeAsContent(parent, child) {
|
|
307
|
+
// Decide if 'child' should be merged into 'parent' content instead of being a new section.
|
|
308
|
+
// 1. If child has no content and is short?
|
|
309
|
+
// 2. If parent matches known strictly-list sections (Assumptions, Evidence, Unknowns)
|
|
310
|
+
// List of keys that usually contain lists of items as siblings in badly formatted markdown
|
|
311
|
+
const LIST_SECTIONS = [
|
|
312
|
+
'assumptions',
|
|
313
|
+
'unknowns',
|
|
314
|
+
'evidence',
|
|
315
|
+
'examples',
|
|
316
|
+
'notes',
|
|
317
|
+
'analysis',
|
|
318
|
+
'findings',
|
|
319
|
+
'recommendations',
|
|
320
|
+
'considerations'
|
|
321
|
+
];
|
|
322
|
+
const parentKey = toCamelCase(parent.heading);
|
|
323
|
+
const childKey = toCamelCase(child.heading);
|
|
324
|
+
// If the child is itself a known list section, do NOT merge it.
|
|
325
|
+
// It should be a new section.
|
|
326
|
+
if (LIST_SECTIONS.includes(childKey)) {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
if (LIST_SECTIONS.includes(parentKey)) {
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
255
334
|
}
|
|
256
335
|
//# sourceMappingURL=parser.js.map
|
package/dist/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAmB,UAAU,EAAiB,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,OAAO,YAAY;IACb,SAAS,GAAG,OAAO,EAAE;SACxB,GAAG,CAAC,WAAW,CAAC;SAChB,GAAG,CAAC,SAAS,CAAC,CAAC;IAEZ,OAAO,CAA0B;IAEzC,YAAY,UAAyB,EAAE;QACnC,IAAI,CAAC,OAAO,GAAG;YACX,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI;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;YACpC,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect-bullet-mode.d.ts","sourceRoot":"","sources":["../../src/plugins/detect-bullet-mode.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,gBAAgB;
|
|
1
|
+
{"version":3,"file":"detect-bullet-mode.d.ts","sourceRoot":"","sources":["../../src/plugins/detect-bullet-mode.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB;AAWD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,GAAG,GAAG,gBAAgB,CA8I5D"}
|
|
@@ -8,7 +8,8 @@ const SECTION_KEYWORDS = [
|
|
|
8
8
|
'assumptions', 'unknowns', 'evidence', 'notes', 'details',
|
|
9
9
|
'description', 'background', 'analysis', 'findings', 'recommendations',
|
|
10
10
|
'data', 'identity', 'network', 'security', 'monitoring', 'governance',
|
|
11
|
-
'availability', 'backup', 'patch', 'operational', 'provider'
|
|
11
|
+
'availability', 'backup', 'patch', 'operational', 'provider',
|
|
12
|
+
'short', 'full', 'long' // Added common answer prefixes
|
|
12
13
|
];
|
|
13
14
|
export function detectBulletMode(tree) {
|
|
14
15
|
const reasons = [];
|
|
@@ -78,8 +79,9 @@ export function detectBulletMode(tree) {
|
|
|
78
79
|
reasons.push(`${bulletsWithNestedLists} bullets have nested lists - section indicator`);
|
|
79
80
|
}
|
|
80
81
|
if (bulletsWithKeywords > 0) {
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
// Huge boost for keywords - these are almost certainly section headers
|
|
83
|
+
sectionScore += 10;
|
|
84
|
+
reasons.push(`${bulletsWithKeywords} bullets contain section keywords - STRONG section indicator`);
|
|
83
85
|
}
|
|
84
86
|
if (avgLength > 30) {
|
|
85
87
|
sectionScore += 1;
|
|
@@ -90,9 +92,10 @@ export function detectBulletMode(tree) {
|
|
|
90
92
|
reasons.push('Few bullets with rich content suggests sections');
|
|
91
93
|
}
|
|
92
94
|
// === SCORING FOR ARRAY MODE ===
|
|
93
|
-
if (bulletsWithColons === 0 && bulletsWithContent === 0 && bulletsWithNestedLists === 0) {
|
|
95
|
+
if (bulletsWithColons === 0 && bulletsWithContent === 0 && bulletsWithNestedLists === 0 && bulletsWithKeywords === 0) {
|
|
96
|
+
// Only if NO keywords are found
|
|
94
97
|
arrayScore += 4;
|
|
95
|
-
reasons.push('No bullets have content, colons,
|
|
98
|
+
reasons.push('No bullets have content, colons, nesting, OR keywords - pure list indicator');
|
|
96
99
|
}
|
|
97
100
|
if (avgLength < 30) {
|
|
98
101
|
arrayScore += 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect-bullet-mode.js","sourceRoot":"","sources":["../../src/plugins/detect-bullet-mode.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAQhD,MAAM,gBAAgB,GAAG;
|
|
1
|
+
{"version":3,"file":"detect-bullet-mode.js","sourceRoot":"","sources":["../../src/plugins/detect-bullet-mode.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAQhD,MAAM,gBAAgB,GAAG;IACrB,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU;IAC7D,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS;IACzD,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB;IACtE,MAAM,EAAE,UAAU,EAA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
|
currentNodes = [];
|
|
61
61
|
|
|
62
|
-
} else if (node.type === 'list' && bulletMode === BulletMode.SECTIONS) {
|
|
62
|
+
} else if (node.type === 'list' && !node.ordered && bulletMode === BulletMode.SECTIONS) {
|
|
63
63
|
// Bullet-style sections mode: each root-level bullet is a section
|
|
64
64
|
if (currentSection) {
|
|
65
65
|
this.mergeAndPushSection(sections, currentSection, currentNodes, bulletMode);
|
|
@@ -69,19 +69,71 @@ export class RemarkParser {
|
|
|
69
69
|
|
|
70
70
|
// Process each list item as a section
|
|
71
71
|
const newSections: MarkdownSection[] = [];
|
|
72
|
+
|
|
73
|
+
// If we have a current section pending content, and this list is just text items, maybe it belongs to currentSection?
|
|
74
|
+
// But detect-bullet-mode says SECTIONS. So we expect sections.
|
|
75
|
+
|
|
72
76
|
for (const listItem of node.children) {
|
|
73
77
|
newSections.push(...this.processBulletAsSection(listItem));
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
if (newSections.length > 0) {
|
|
81
|
+
// Refined Sibling Logic:
|
|
82
|
+
// If a section has empty content, and is followed by sections that look like simple items...
|
|
83
|
+
// But processBulletAsSection transforms every item into a section.
|
|
84
|
+
// We need to merge them if they are actually content.
|
|
85
|
+
|
|
86
|
+
// Post-processing merge:
|
|
87
|
+
const mergedSections: MarkdownSection[] = [];
|
|
88
|
+
let activeSection: MarkdownSection | null = null;
|
|
89
|
+
|
|
90
|
+
for (const sec of newSections) {
|
|
91
|
+
// Heuristic: Is this really a section or just an item?
|
|
92
|
+
// If detect-bullet-mode said SECTIONS, usually we trust it.
|
|
93
|
+
// But for mixed lists: "- Assumptions" (sec) "- Item 1" (sec?) "- Item 2" (sec?)
|
|
94
|
+
|
|
95
|
+
// Check if 'sec' looks like a property or a value.
|
|
96
|
+
// Ideally strictly, everything is a property.
|
|
97
|
+
// But in the test case "- Assumptions \n - Val 1 \n - Val 2",
|
|
98
|
+
// they are siblings.
|
|
99
|
+
|
|
100
|
+
if (activeSection && this.shouldMergeAsContent(activeSection, sec)) {
|
|
101
|
+
// Merge content
|
|
102
|
+
if (!activeSection.content) {
|
|
103
|
+
activeSection.content = [sec.heading]; // Use heading as value
|
|
104
|
+
} else if (Array.isArray(activeSection.content)) {
|
|
105
|
+
activeSection.content.push(sec.heading);
|
|
106
|
+
} else {
|
|
107
|
+
// Convert existing string content to array? Or mix?
|
|
108
|
+
activeSection.content = [activeSection.content, sec.heading];
|
|
109
|
+
}
|
|
110
|
+
// APPEND any content of sec as well?
|
|
111
|
+
if (sec.content) {
|
|
112
|
+
if (Array.isArray(sec.content)) {
|
|
113
|
+
(activeSection.content as any[]).push(...sec.content);
|
|
114
|
+
} else {
|
|
115
|
+
(activeSection.content as any[]).push(sec.content);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
activeSection = sec;
|
|
120
|
+
mergedSections.push(sec);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
77
124
|
// Push all except the last one as complete sections
|
|
78
|
-
|
|
79
|
-
|
|
125
|
+
if (mergedSections.length > 0) {
|
|
126
|
+
for (let i = 0; i < mergedSections.length - 1; i++) {
|
|
127
|
+
sections.push(mergedSections[i]!);
|
|
128
|
+
}
|
|
129
|
+
// Keep the last one as currentSection to capture subsequent loose content
|
|
130
|
+
currentSection = mergedSections[mergedSections.length - 1]!;
|
|
80
131
|
}
|
|
81
|
-
// Keep the last one as currentSection to capture subsequent loose content
|
|
82
|
-
currentSection = newSections[newSections.length - 1]!;
|
|
83
132
|
}
|
|
84
133
|
|
|
134
|
+
|
|
135
|
+
// Original simple loop removed in favor of refined logic above
|
|
136
|
+
|
|
85
137
|
} else {
|
|
86
138
|
currentNodes.push(node);
|
|
87
139
|
}
|
|
@@ -192,9 +244,9 @@ export class RemarkParser {
|
|
|
192
244
|
items: nestedArray
|
|
193
245
|
};
|
|
194
246
|
} else {
|
|
195
|
-
//
|
|
247
|
+
// Flatten all other children into text
|
|
196
248
|
const nodeText = contentNodes
|
|
197
|
-
.map((node: any) =>
|
|
249
|
+
.map((node: any) => this.nodeToString(node))
|
|
198
250
|
.join('\n\n')
|
|
199
251
|
.trim();
|
|
200
252
|
content = sameNodeContent ? sameNodeContent + '\n\n' + nodeText : nodeText;
|
|
@@ -260,13 +312,7 @@ export class RemarkParser {
|
|
|
260
312
|
}
|
|
261
313
|
|
|
262
314
|
private mergeAndPushSection(sections: MarkdownSection[], section: MarkdownSection, nodes: any[], bulletMode: BulletMode) {
|
|
263
|
-
//
|
|
264
|
-
// we shouldn't push it again?
|
|
265
|
-
// Wait, my logic implementation in loop:
|
|
266
|
-
// "newSections.push(...); if (newSections.length > 0) { ... loop push n-1 ... currentSection = nth }"
|
|
267
|
-
// So currentSection is NOT in sections yet.
|
|
268
|
-
// It's safe to push.
|
|
269
|
-
|
|
315
|
+
// ... (existing implementation)
|
|
270
316
|
const newContent = this.processContent(nodes, bulletMode);
|
|
271
317
|
|
|
272
318
|
if (newContent) {
|
|
@@ -285,4 +331,47 @@ export class RemarkParser {
|
|
|
285
331
|
|
|
286
332
|
sections.push(section);
|
|
287
333
|
}
|
|
334
|
+
|
|
335
|
+
private nodeToString(node: any): string {
|
|
336
|
+
if (node.type === 'table') {
|
|
337
|
+
return JSON.stringify(this.tableToArray(node));
|
|
338
|
+
}
|
|
339
|
+
if (node.type === 'list') {
|
|
340
|
+
return this.listToArray(node).map(item => `- ${item}`).join('\n');
|
|
341
|
+
}
|
|
342
|
+
return toString(node);
|
|
343
|
+
}
|
|
344
|
+
private shouldMergeAsContent(parent: MarkdownSection, child: MarkdownSection): boolean {
|
|
345
|
+
// Decide if 'child' should be merged into 'parent' content instead of being a new section.
|
|
346
|
+
|
|
347
|
+
// 1. If child has no content and is short?
|
|
348
|
+
// 2. If parent matches known strictly-list sections (Assumptions, Evidence, Unknowns)
|
|
349
|
+
|
|
350
|
+
// List of keys that usually contain lists of items as siblings in badly formatted markdown
|
|
351
|
+
const LIST_SECTIONS = [
|
|
352
|
+
'assumptions',
|
|
353
|
+
'unknowns',
|
|
354
|
+
'evidence',
|
|
355
|
+
'examples',
|
|
356
|
+
'notes',
|
|
357
|
+
'analysis',
|
|
358
|
+
'findings',
|
|
359
|
+
'recommendations',
|
|
360
|
+
'considerations'
|
|
361
|
+
];
|
|
362
|
+
const parentKey = toCamelCase(parent.heading);
|
|
363
|
+
const childKey = toCamelCase(child.heading);
|
|
364
|
+
|
|
365
|
+
// If the child is itself a known list section, do NOT merge it.
|
|
366
|
+
// It should be a new section.
|
|
367
|
+
if (LIST_SECTIONS.includes(childKey)) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (LIST_SECTIONS.includes(parentKey)) {
|
|
372
|
+
return true;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
288
377
|
}
|
|
@@ -5,157 +5,160 @@ import { visit } from 'unist-util-visit';
|
|
|
5
5
|
import { toString } from 'mdast-util-to-string';
|
|
6
6
|
|
|
7
7
|
export interface BulletModeResult {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
mode: 'array' | 'sections';
|
|
9
|
+
confidence: number;
|
|
10
|
+
reasons: string[];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const SECTION_KEYWORDS = [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
'answer', 'summary', 'introduction', 'conclusion', 'overview',
|
|
15
|
+
'assumptions', 'unknowns', 'evidence', 'notes', 'details',
|
|
16
|
+
'description', 'background', 'analysis', 'findings', 'recommendations',
|
|
17
|
+
'data', 'identity', 'network', 'security', 'monitoring', 'governance',
|
|
18
|
+
'availability', 'backup', 'patch', 'operational', 'provider',
|
|
19
|
+
'short', 'full', 'long' // Added common answer prefixes
|
|
19
20
|
];
|
|
20
21
|
|
|
21
22
|
export function detectBulletMode(tree: any): BulletModeResult {
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
23
|
+
const reasons: string[] = [];
|
|
24
|
+
let sectionScore = 0;
|
|
25
|
+
let arrayScore = 0;
|
|
26
|
+
|
|
27
|
+
let bulletCount = 0;
|
|
28
|
+
let bulletsWithContent = 0;
|
|
29
|
+
let bulletsWithColons = 0;
|
|
30
|
+
let bulletsWithNestedLists = 0;
|
|
31
|
+
let bulletsWithKeywords = 0;
|
|
32
|
+
let totalBulletLength = 0;
|
|
33
|
+
let rootLevelBullets = 0;
|
|
34
|
+
|
|
35
|
+
// Analyze the tree structure
|
|
36
|
+
visit(tree, 'list', (listNode: any, index?: number, parent?: any) => {
|
|
37
|
+
// Only analyze root-level lists or lists directly under root
|
|
38
|
+
const isRootLevel = parent?.type === 'root';
|
|
39
|
+
|
|
40
|
+
if (!isRootLevel) return;
|
|
41
|
+
|
|
42
|
+
rootLevelBullets += listNode.children.length;
|
|
43
|
+
|
|
44
|
+
for (const listItem of listNode.children) {
|
|
45
|
+
bulletCount++;
|
|
46
|
+
|
|
47
|
+
// Get the text of this list item (first paragraph/text only)
|
|
48
|
+
const firstChild = listItem.children[0];
|
|
49
|
+
const itemText = firstChild ? toString(firstChild) : '';
|
|
50
|
+
totalBulletLength += itemText.length;
|
|
51
|
+
|
|
52
|
+
// 1. Check for colons (title pattern: "Short answer:" or "Data protection:")
|
|
53
|
+
if (itemText.includes(':')) {
|
|
54
|
+
bulletsWithColons++;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 2. Check for content after the bullet (paragraphs, nested items)
|
|
58
|
+
if (listItem.children.length > 1) {
|
|
59
|
+
bulletsWithContent++;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 3. Check for nested lists
|
|
63
|
+
const hasNestedList = listItem.children.some((child: any) => child.type === 'list');
|
|
64
|
+
if (hasNestedList) {
|
|
65
|
+
bulletsWithNestedLists++;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 4. Check for section keywords
|
|
69
|
+
const lowerText = itemText.toLowerCase();
|
|
70
|
+
if (SECTION_KEYWORDS.some(kw => lowerText.includes(kw))) {
|
|
71
|
+
bulletsWithKeywords++;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
if (bulletCount === 0) {
|
|
77
|
+
return {
|
|
78
|
+
mode: 'array',
|
|
79
|
+
confidence: 0,
|
|
80
|
+
reasons: ['No bullets found']
|
|
81
|
+
};
|
|
72
82
|
}
|
|
73
|
-
});
|
|
74
83
|
|
|
75
|
-
|
|
84
|
+
const avgLength = totalBulletLength / bulletCount;
|
|
85
|
+
|
|
86
|
+
// === SCORING FOR SECTIONS MODE ===
|
|
87
|
+
|
|
88
|
+
if (bulletsWithColons > 0) {
|
|
89
|
+
const percent = (bulletsWithColons / bulletCount * 100).toFixed(0);
|
|
90
|
+
sectionScore += 3;
|
|
91
|
+
reasons.push(`${bulletsWithColons}/${bulletCount} bullets have colons (${percent}%) - strong section indicator`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (bulletsWithContent > 0) {
|
|
95
|
+
const percent = (bulletsWithContent / bulletCount * 100).toFixed(0);
|
|
96
|
+
sectionScore += 3;
|
|
97
|
+
reasons.push(`${bulletsWithContent}/${bulletCount} bullets have content below (${percent}%) - strong section indicator`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (bulletsWithNestedLists > 0) {
|
|
101
|
+
sectionScore += 2;
|
|
102
|
+
reasons.push(`${bulletsWithNestedLists} bullets have nested lists - section indicator`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (bulletsWithKeywords > 0) {
|
|
106
|
+
// Huge boost for keywords - these are almost certainly section headers
|
|
107
|
+
sectionScore += 10;
|
|
108
|
+
reasons.push(`${bulletsWithKeywords} bullets contain section keywords - STRONG section indicator`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (avgLength > 30) {
|
|
112
|
+
sectionScore += 1;
|
|
113
|
+
reasons.push(`Long bullet text (avg ${avgLength.toFixed(0)} chars) - suggests titles`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (bulletCount <= 5 && (bulletsWithContent > 0 || bulletsWithColons > 0)) {
|
|
117
|
+
sectionScore += 1;
|
|
118
|
+
reasons.push('Few bullets with rich content suggests sections');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// === SCORING FOR ARRAY MODE ===
|
|
122
|
+
|
|
123
|
+
if (bulletsWithColons === 0 && bulletsWithContent === 0 && bulletsWithNestedLists === 0 && bulletsWithKeywords === 0) {
|
|
124
|
+
// Only if NO keywords are found
|
|
125
|
+
arrayScore += 4;
|
|
126
|
+
reasons.push('No bullets have content, colons, nesting, OR keywords - pure list indicator');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (avgLength < 30) {
|
|
130
|
+
arrayScore += 2;
|
|
131
|
+
reasons.push(`Short bullet text (avg ${avgLength.toFixed(0)} chars) - suggests list items`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (bulletCount >= 3 && bulletsWithContent === 0) {
|
|
135
|
+
arrayScore += 2;
|
|
136
|
+
reasons.push(`${bulletCount} simple bullets without content - array pattern`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (bulletsWithKeywords === 0) {
|
|
140
|
+
arrayScore += 1;
|
|
141
|
+
reasons.push('No section keywords found');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Edge case: all bullets are very short and no special features
|
|
145
|
+
if (avgLength < 20 && bulletsWithContent === 0 && bulletsWithColons === 0) {
|
|
146
|
+
arrayScore += 2;
|
|
147
|
+
reasons.push('Very short bullets with no features - definitely array');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// === DECISION ===
|
|
151
|
+
|
|
152
|
+
const totalScore = sectionScore + arrayScore;
|
|
153
|
+
const mode = sectionScore > arrayScore ? 'sections' : 'array';
|
|
154
|
+
const confidence = totalScore > 0 ? Math.abs(sectionScore - arrayScore) / totalScore : 0;
|
|
155
|
+
|
|
156
|
+
// Format reasons (top 5)
|
|
157
|
+
const topReasons = reasons.slice(0, 5);
|
|
158
|
+
|
|
76
159
|
return {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
160
|
+
mode,
|
|
161
|
+
confidence,
|
|
162
|
+
reasons: topReasons
|
|
80
163
|
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const avgLength = totalBulletLength / bulletCount;
|
|
84
|
-
|
|
85
|
-
// === SCORING FOR SECTIONS MODE ===
|
|
86
|
-
|
|
87
|
-
if (bulletsWithColons > 0) {
|
|
88
|
-
const percent = (bulletsWithColons / bulletCount * 100).toFixed(0);
|
|
89
|
-
sectionScore += 3;
|
|
90
|
-
reasons.push(`${bulletsWithColons}/${bulletCount} bullets have colons (${percent}%) - strong section indicator`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (bulletsWithContent > 0) {
|
|
94
|
-
const percent = (bulletsWithContent / bulletCount * 100).toFixed(0);
|
|
95
|
-
sectionScore += 3;
|
|
96
|
-
reasons.push(`${bulletsWithContent}/${bulletCount} bullets have content below (${percent}%) - strong section indicator`);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (bulletsWithNestedLists > 0) {
|
|
100
|
-
sectionScore += 2;
|
|
101
|
-
reasons.push(`${bulletsWithNestedLists} bullets have nested lists - section indicator`);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (bulletsWithKeywords > 0) {
|
|
105
|
-
sectionScore += 2;
|
|
106
|
-
reasons.push(`${bulletsWithKeywords} bullets contain section keywords`);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (avgLength > 30) {
|
|
110
|
-
sectionScore += 1;
|
|
111
|
-
reasons.push(`Long bullet text (avg ${avgLength.toFixed(0)} chars) - suggests titles`);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (bulletCount <= 5 && (bulletsWithContent > 0 || bulletsWithColons > 0)) {
|
|
115
|
-
sectionScore += 1;
|
|
116
|
-
reasons.push('Few bullets with rich content suggests sections');
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// === SCORING FOR ARRAY MODE ===
|
|
120
|
-
|
|
121
|
-
if (bulletsWithColons === 0 && bulletsWithContent === 0 && bulletsWithNestedLists === 0) {
|
|
122
|
-
arrayScore += 4;
|
|
123
|
-
reasons.push('No bullets have content, colons, or nesting - pure list indicator');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (avgLength < 30) {
|
|
127
|
-
arrayScore += 2;
|
|
128
|
-
reasons.push(`Short bullet text (avg ${avgLength.toFixed(0)} chars) - suggests list items`);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (bulletCount >= 3 && bulletsWithContent === 0) {
|
|
132
|
-
arrayScore += 2;
|
|
133
|
-
reasons.push(`${bulletCount} simple bullets without content - array pattern`);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (bulletsWithKeywords === 0) {
|
|
137
|
-
arrayScore += 1;
|
|
138
|
-
reasons.push('No section keywords found');
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Edge case: all bullets are very short and no special features
|
|
142
|
-
if (avgLength < 20 && bulletsWithContent === 0 && bulletsWithColons === 0) {
|
|
143
|
-
arrayScore += 2;
|
|
144
|
-
reasons.push('Very short bullets with no features - definitely array');
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// === DECISION ===
|
|
148
|
-
|
|
149
|
-
const totalScore = sectionScore + arrayScore;
|
|
150
|
-
const mode = sectionScore > arrayScore ? 'sections' : 'array';
|
|
151
|
-
const confidence = totalScore > 0 ? Math.abs(sectionScore - arrayScore) / totalScore : 0;
|
|
152
|
-
|
|
153
|
-
// Format reasons (top 5)
|
|
154
|
-
const topReasons = reasons.slice(0, 5);
|
|
155
|
-
|
|
156
|
-
return {
|
|
157
|
-
mode,
|
|
158
|
-
confidence,
|
|
159
|
-
reasons: topReasons
|
|
160
|
-
};
|
|
161
164
|
}
|
package/test/parser.2.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { markdownToJson } from '../src/index.js';
|
|
2
2
|
|
|
3
3
|
describe('nx-json-parser - Complex Input', () => {
|
|
4
|
-
|
|
4
|
+
const str = `- Short answer
|
|
5
5
|
Key considerations include data protection (encryption at rest and in transit), strong access control and IAM, secure network design, configuration and patch management, monitoring and logging, backups and disaster recovery, compliance and governance, and a clear shared responsibility model with incident response planning.
|
|
6
6
|
|
|
7
7
|
- Full answer
|
|
@@ -87,17 +87,17 @@ Deploying a database in the cloud shifts part of the security burden to the clou
|
|
|
87
87
|
11. Data residency considerations: Data localization requirements can influence data storage and transfer controls.
|
|
88
88
|
12. Vendor/service model considerations: Clear understanding of the provider’s and customer’s security responsibilities and controls is essential for effective security posture.`;
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
it('should parse the large security overview correctly', () => {
|
|
91
|
+
const result = markdownToJson(str);
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
expect(result.shortAnswer).toBeDefined();
|
|
94
|
+
expect(result.fullAnswer).toBeDefined();
|
|
95
|
+
expect(result.dataProtection).toBeDefined();
|
|
96
|
+
expect(result.accessControlAndIdentityManagement).toBeDefined();
|
|
97
|
+
expect(result.assumptions).toBeInstanceOf(Array);
|
|
98
|
+
expect(result.evidence).toBeInstanceOf(Array);
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
expect((result.evidence as string[]).length).toBe(12);
|
|
101
|
+
expect(result.shortAnswer).toContain('Key considerations include data protection');
|
|
102
|
+
});
|
|
103
103
|
});
|