nx-json-parser 1.0.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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/parser.d.ts +24 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +270 -13
- package/dist/parser.js.map +1 -1
- package/dist/plugins/bullet-sections.d.ts.map +1 -1
- package/dist/plugins/bullet-sections.js +42 -72
- package/dist/plugins/bullet-sections.js.map +1 -1
- package/dist/plugins/detect-bullet-mode.d.ts +7 -0
- package/dist/plugins/detect-bullet-mode.d.ts.map +1 -0
- package/dist/plugins/detect-bullet-mode.js +129 -0
- package/dist/plugins/detect-bullet-mode.js.map +1 -0
- package/dist/remark-markdown-parser.d.ts +41 -0
- package/dist/remark-markdown-parser.d.ts.map +1 -0
- package/dist/remark-markdown-parser.js +294 -0
- package/dist/remark-markdown-parser.js.map +1 -0
- package/dist/types.d.ts +17 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/parser.ts +302 -15
- package/src/plugins/bullet-sections.ts +58 -83
- package/src/plugins/bullet-sections.ts.old +86 -0
- package/src/plugins/detect-bullet-mode.ts +164 -0
- package/src/remark-markdown-parser.ts +340 -0
- package/src/types.ts +22 -6
- package/test/bullet-mode.test.ts +99 -0
- package/test/parser.2.test.ts +12 -12
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAI7C;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAGpD"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC3C,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC;IAC1C,OAAO,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AAC3C,CAAC"}
|
package/dist/parser.d.ts
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
|
-
import { MarkdownSection } from './types.js';
|
|
1
|
+
import { MarkdownSection, ParserOptions } from './types.js';
|
|
2
2
|
export declare class RemarkParser {
|
|
3
3
|
private processor;
|
|
4
|
+
private options;
|
|
5
|
+
constructor(options?: ParserOptions);
|
|
4
6
|
parse(markdown: string): MarkdownSection[];
|
|
7
|
+
/**
|
|
8
|
+
* Process content nodes into appropriate format
|
|
9
|
+
*/
|
|
5
10
|
private processContent;
|
|
11
|
+
/**
|
|
12
|
+
* Process a bullet list item as a section (Mode 2: SECTIONS)
|
|
13
|
+
*/
|
|
14
|
+
private processBulletAsSection;
|
|
15
|
+
/**
|
|
16
|
+
* Convert list to simple array of strings (Mode 1: ARRAY)
|
|
17
|
+
*/
|
|
18
|
+
private listToArray;
|
|
19
|
+
/**
|
|
20
|
+
* Convert table to array of objects
|
|
21
|
+
*/
|
|
6
22
|
private tableToArray;
|
|
23
|
+
/**
|
|
24
|
+
* Convert sections to object (utility method)
|
|
25
|
+
*/
|
|
26
|
+
sectionsToObject(sections: MarkdownSection[]): Record<string, any>;
|
|
27
|
+
private mergeAndPushSection;
|
|
28
|
+
private nodeToString;
|
|
29
|
+
private shouldMergeAsContent;
|
|
7
30
|
}
|
|
8
31
|
//# sourceMappingURL=parser.d.ts.map
|
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,EAAE,MAAM,YAAY,CAAC;
|
|
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
|
@@ -2,24 +2,44 @@ import { unified } from 'unified';
|
|
|
2
2
|
import remarkParse from 'remark-parse';
|
|
3
3
|
import remarkGfm from 'remark-gfm';
|
|
4
4
|
import { toString } from 'mdast-util-to-string';
|
|
5
|
-
import {
|
|
5
|
+
import { BulletMode } from './types.js';
|
|
6
|
+
import { detectBulletMode } from './plugins/detect-bullet-mode.js';
|
|
6
7
|
import { toCamelCase } from 'nx-helpers';
|
|
7
8
|
export class RemarkParser {
|
|
8
9
|
processor = unified()
|
|
9
10
|
.use(remarkParse)
|
|
10
|
-
.use(remarkGfm)
|
|
11
|
-
|
|
11
|
+
.use(remarkGfm);
|
|
12
|
+
options;
|
|
13
|
+
constructor(options = {}) {
|
|
14
|
+
this.options = {
|
|
15
|
+
bulletMode: options.bulletMode ?? BulletMode.AUTO,
|
|
16
|
+
debug: options.debug ?? false
|
|
17
|
+
};
|
|
18
|
+
}
|
|
12
19
|
parse(markdown) {
|
|
13
20
|
const tree = this.processor.runSync(this.processor.parse(markdown));
|
|
21
|
+
// Detect bullet mode if AUTO
|
|
22
|
+
let bulletMode = this.options.bulletMode;
|
|
23
|
+
if (bulletMode === BulletMode.AUTO) {
|
|
24
|
+
const detection = detectBulletMode(tree);
|
|
25
|
+
bulletMode = detection.mode === 'sections' ? BulletMode.SECTIONS : BulletMode.ARRAY;
|
|
26
|
+
if (this.options.debug) {
|
|
27
|
+
console.log('🔍 Bullet Mode Detection:');
|
|
28
|
+
console.log(` Mode: ${detection.mode}`);
|
|
29
|
+
console.log(` Confidence: ${(detection.confidence * 100).toFixed(0)}%`);
|
|
30
|
+
console.log(` Reasons:`);
|
|
31
|
+
detection.reasons.forEach(r => console.log(` - ${r}`));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
14
34
|
const sections = [];
|
|
15
35
|
let currentSection = null;
|
|
16
36
|
let currentNodes = [];
|
|
17
37
|
const rootChildren = tree.children;
|
|
18
38
|
for (const node of rootChildren) {
|
|
19
39
|
if (node.type === 'heading') {
|
|
40
|
+
// Standard heading section (### Section)
|
|
20
41
|
if (currentSection) {
|
|
21
|
-
|
|
22
|
-
sections.push(currentSection);
|
|
42
|
+
this.mergeAndPushSection(sections, currentSection, currentNodes, bulletMode);
|
|
23
43
|
}
|
|
24
44
|
currentSection = {
|
|
25
45
|
heading: toString(node).trim(),
|
|
@@ -29,43 +49,211 @@ export class RemarkParser {
|
|
|
29
49
|
};
|
|
30
50
|
currentNodes = [];
|
|
31
51
|
}
|
|
52
|
+
else if (node.type === 'list' && !node.ordered && bulletMode === BulletMode.SECTIONS) {
|
|
53
|
+
// Bullet-style sections mode: each root-level bullet is a section
|
|
54
|
+
if (currentSection) {
|
|
55
|
+
this.mergeAndPushSection(sections, currentSection, currentNodes, bulletMode);
|
|
56
|
+
currentSection = null;
|
|
57
|
+
currentNodes = [];
|
|
58
|
+
}
|
|
59
|
+
// Process each list item as a section
|
|
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.
|
|
63
|
+
for (const listItem of node.children) {
|
|
64
|
+
newSections.push(...this.processBulletAsSection(listItem));
|
|
65
|
+
}
|
|
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
|
+
}
|
|
109
|
+
// Push all except the last one as complete sections
|
|
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];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Original simple loop removed in favor of refined logic above
|
|
119
|
+
}
|
|
32
120
|
else {
|
|
33
121
|
currentNodes.push(node);
|
|
34
122
|
}
|
|
35
123
|
}
|
|
124
|
+
// Save last section
|
|
36
125
|
if (currentSection) {
|
|
37
|
-
|
|
38
|
-
sections.push(currentSection);
|
|
126
|
+
this.mergeAndPushSection(sections, currentSection, currentNodes, bulletMode);
|
|
39
127
|
}
|
|
40
128
|
else if (currentNodes.length > 0) {
|
|
129
|
+
// No sections found, put everything in root
|
|
41
130
|
sections.push({
|
|
42
131
|
heading: 'Root',
|
|
43
|
-
content: this.processContent(currentNodes),
|
|
132
|
+
content: this.processContent(currentNodes, bulletMode),
|
|
44
133
|
level: 0,
|
|
45
134
|
format: 'text'
|
|
46
135
|
});
|
|
47
136
|
}
|
|
48
137
|
return sections;
|
|
49
138
|
}
|
|
50
|
-
|
|
139
|
+
/**
|
|
140
|
+
* Process content nodes into appropriate format
|
|
141
|
+
*/
|
|
142
|
+
processContent(nodes, bulletMode) {
|
|
51
143
|
if (nodes.length === 0)
|
|
52
144
|
return '';
|
|
145
|
+
// Single table - return as array of objects
|
|
53
146
|
if (nodes.length === 1 && nodes[0].type === 'table') {
|
|
54
147
|
return this.tableToArray(nodes[0]);
|
|
55
148
|
}
|
|
149
|
+
// Single list - behavior depends on mode
|
|
56
150
|
if (nodes.length === 1 && nodes[0].type === 'list') {
|
|
57
|
-
|
|
151
|
+
if (bulletMode === BulletMode.ARRAY) {
|
|
152
|
+
// Mode 1: Return as simple array of strings
|
|
153
|
+
return this.listToArray(nodes[0]);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
// Mode 2: In sections mode, nested lists are still arrays
|
|
157
|
+
return this.listToArray(nodes[0]);
|
|
158
|
+
}
|
|
58
159
|
}
|
|
160
|
+
// Multiple nodes or mixed content
|
|
59
161
|
return nodes.map(node => {
|
|
60
162
|
if (node.type === 'table') {
|
|
61
|
-
return
|
|
163
|
+
return this.tableToArray(node);
|
|
164
|
+
}
|
|
165
|
+
if (node.type === 'list') {
|
|
166
|
+
return this.listToArray(node);
|
|
62
167
|
}
|
|
63
168
|
return toString(node);
|
|
64
169
|
}).join('\n\n').trim();
|
|
65
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Process a bullet list item as a section (Mode 2: SECTIONS)
|
|
173
|
+
*/
|
|
174
|
+
processBulletAsSection(listItem) {
|
|
175
|
+
const sections = [];
|
|
176
|
+
// First child is the bullet text (section heading)
|
|
177
|
+
const firstChild = listItem.children[0];
|
|
178
|
+
if (!firstChild)
|
|
179
|
+
return sections;
|
|
180
|
+
const rawText = toString(firstChild).trim();
|
|
181
|
+
const lines = rawText.split('\n');
|
|
182
|
+
const heading = lines[0]?.trim() || '';
|
|
183
|
+
const sameNodeContent = lines.slice(1).join('\n').trim();
|
|
184
|
+
// Clean heading: remove trailing colon if present
|
|
185
|
+
const cleanHeading = heading.replace(/:$/, '');
|
|
186
|
+
// Rest of the children are the content
|
|
187
|
+
const contentNodes = listItem.children.slice(1);
|
|
188
|
+
let content;
|
|
189
|
+
if (contentNodes.length === 0) {
|
|
190
|
+
// No extra nodes, but maybe same-node content?
|
|
191
|
+
content = sameNodeContent;
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
// If we have sameNodeContent, we should prepend it to the text content?
|
|
195
|
+
// This gets complicated if contentNodes are mixed.
|
|
196
|
+
// Simplified: If sameNodeContent exists, assume it's part of the text.
|
|
197
|
+
// Check for nested list
|
|
198
|
+
const nestedList = contentNodes.find((node) => node.type === 'list');
|
|
199
|
+
if (nestedList && contentNodes.length === 1) {
|
|
200
|
+
// ONLY a nested list - convert to array
|
|
201
|
+
content = this.listToArray(nestedList);
|
|
202
|
+
}
|
|
203
|
+
else if (nestedList) {
|
|
204
|
+
// Mixed content: paragraphs + nested list
|
|
205
|
+
// For now, convert nested list to array and combine
|
|
206
|
+
const paragraphs = contentNodes
|
|
207
|
+
.filter((node) => node.type !== 'list')
|
|
208
|
+
.map((node) => toString(node))
|
|
209
|
+
.join('\n\n')
|
|
210
|
+
.trim();
|
|
211
|
+
const fullText = sameNodeContent ? sameNodeContent + '\n\n' + paragraphs : paragraphs;
|
|
212
|
+
const nestedArray = this.listToArray(nestedList);
|
|
213
|
+
// Combine: return object with text and items
|
|
214
|
+
content = {
|
|
215
|
+
text: fullText,
|
|
216
|
+
items: nestedArray
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
// Flatten all other children into text
|
|
221
|
+
const nodeText = contentNodes
|
|
222
|
+
.map((node) => this.nodeToString(node))
|
|
223
|
+
.join('\n\n')
|
|
224
|
+
.trim();
|
|
225
|
+
content = sameNodeContent ? sameNodeContent + '\n\n' + nodeText : nodeText;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
sections.push({
|
|
229
|
+
heading: cleanHeading,
|
|
230
|
+
content,
|
|
231
|
+
level: 1,
|
|
232
|
+
format: 'bullet'
|
|
233
|
+
});
|
|
234
|
+
return sections;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Convert list to simple array of strings (Mode 1: ARRAY)
|
|
238
|
+
*/
|
|
239
|
+
listToArray(listNode) {
|
|
240
|
+
return listNode.children.map((item) => {
|
|
241
|
+
// Get just the first paragraph/text, ignore nested content
|
|
242
|
+
const firstChild = item.children[0];
|
|
243
|
+
return toString(firstChild).trim();
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Convert table to array of objects
|
|
248
|
+
*/
|
|
66
249
|
tableToArray(tableNode) {
|
|
67
|
-
const
|
|
68
|
-
|
|
250
|
+
const rows = tableNode.children;
|
|
251
|
+
if (rows.length === 0)
|
|
252
|
+
return [];
|
|
253
|
+
// First row = headers
|
|
254
|
+
const headers = rows[0].children.map((cell) => toCamelCase(toString(cell).trim()));
|
|
255
|
+
// Remaining rows = data
|
|
256
|
+
return rows.slice(1).map((row) => {
|
|
69
257
|
const obj = {};
|
|
70
258
|
row.children.forEach((cell, i) => {
|
|
71
259
|
const key = headers[i] || `column${i}`;
|
|
@@ -74,5 +262,74 @@ export class RemarkParser {
|
|
|
74
262
|
return obj;
|
|
75
263
|
});
|
|
76
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* Convert sections to object (utility method)
|
|
267
|
+
*/
|
|
268
|
+
sectionsToObject(sections) {
|
|
269
|
+
const result = {};
|
|
270
|
+
for (const section of sections) {
|
|
271
|
+
const key = toCamelCase(section.heading);
|
|
272
|
+
result[key] = section.content;
|
|
273
|
+
}
|
|
274
|
+
return result;
|
|
275
|
+
}
|
|
276
|
+
mergeAndPushSection(sections, section, nodes, bulletMode) {
|
|
277
|
+
// ... (existing implementation)
|
|
278
|
+
const newContent = this.processContent(nodes, bulletMode);
|
|
279
|
+
if (newContent) {
|
|
280
|
+
if (!section.content) {
|
|
281
|
+
section.content = newContent;
|
|
282
|
+
}
|
|
283
|
+
else if (typeof section.content === 'string' && typeof newContent === 'string') {
|
|
284
|
+
section.content += '\n\n' + newContent;
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
if (Array.isArray(section.content)) {
|
|
288
|
+
section.content.push(newContent);
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
section.content = [section.content, newContent];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
sections.push(section);
|
|
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
|
+
}
|
|
77
334
|
}
|
|
78
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;AAEhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,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;SACd,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAE/B,KAAK,CAAC,QAAgB;QAClB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;QACpE,MAAM,QAAQ,GAAsB,EAAE,CAAC;QACvC,IAAI,cAAc,GAA2B,IAAI,CAAC;QAClD,IAAI,YAAY,GAAU,EAAE,CAAC;QAE7B,MAAM,YAAY,GAAI,IAAY,CAAC,QAA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":"","sources":["../../src/plugins/bullet-sections.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bullet-sections.d.ts","sourceRoot":"","sources":["../../src/plugins/bullet-sections.ts"],"names":[],"mappings":"AAgBA,wBAAgB,oBAAoB,KAC1B,MAAM,GAAG,UAqBjB"}
|
|
@@ -1,79 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remark plugin to handle bullet-style sections
|
|
3
|
+
* Converts bullets that look like sections into heading nodes
|
|
4
|
+
*/
|
|
5
|
+
import { visit } from 'unist-util-visit';
|
|
1
6
|
import { toString } from 'mdast-util-to-string';
|
|
7
|
+
const SECTION_KEYWORDS = [
|
|
8
|
+
'answer', 'summary', 'introduction', 'conclusion', 'overview',
|
|
9
|
+
'assumptions', 'unknowns', 'evidence', 'notes', 'details',
|
|
10
|
+
'description', 'background', 'analysis', 'findings', 'recommendations',
|
|
11
|
+
'data', 'identity', 'network', 'security', 'monitoring', 'governance',
|
|
12
|
+
'availability', 'backup', 'patch', 'operational', 'provider'
|
|
13
|
+
];
|
|
2
14
|
export function remarkBulletSections() {
|
|
3
15
|
return (tree) => {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const newRootNodes = [];
|
|
14
|
-
let currentListItems = [];
|
|
15
|
-
items.forEach((item, idx) => {
|
|
16
|
-
const firstChild = item.children[0];
|
|
17
|
-
const text = firstChild ? toString(firstChild) : '';
|
|
18
|
-
const lines = text.trim().split('\n');
|
|
19
|
-
const firstLine = lines[0]?.trim() || '';
|
|
20
|
-
const isShort = firstLine.length > 0 && firstLine.length < 150;
|
|
21
|
-
const hasMoreContent = lines.length > 1 || item.children.length > 1;
|
|
22
|
-
// Section detection:
|
|
23
|
-
// 1. It's short and has more content.
|
|
24
|
-
// 2. OR it's short and is followed by a non-short item? (Hard to check here)
|
|
25
|
-
// 3. OR it's one of the "known" section keywords.
|
|
26
|
-
const keywords = ['answer', 'assumptions', 'unknowns', 'evidence', 'protection', 'control', 'management', 'design', 'logging', 'monitoring', 'backups', 'compliance', 'governance', 'modeling', 'incident', 'vendor', 'changes'];
|
|
27
|
-
const isSectionKeyword = keywords.some(k => firstLine.toLowerCase().includes(k));
|
|
28
|
-
if (isShort && (hasMoreContent || isSectionKeyword)) {
|
|
29
|
-
// Flush existing list items if any
|
|
30
|
-
if (currentListItems.length > 0) {
|
|
31
|
-
newRootNodes.push({
|
|
32
|
-
type: 'list',
|
|
33
|
-
ordered: false,
|
|
34
|
-
children: [...currentListItems]
|
|
35
|
-
});
|
|
36
|
-
currentListItems = [];
|
|
37
|
-
}
|
|
38
|
-
// Add as heading
|
|
39
|
-
newRootNodes.push({
|
|
40
|
-
type: 'heading',
|
|
41
|
-
depth: 2,
|
|
42
|
-
children: [{ type: 'text', value: firstLine }]
|
|
43
|
-
});
|
|
44
|
-
// Add content
|
|
45
|
-
if (lines.length > 1) {
|
|
46
|
-
newRootNodes.push({
|
|
47
|
-
type: 'paragraph',
|
|
48
|
-
children: [{ type: 'text', value: lines.slice(1).join('\n').trim() }]
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (item.children.length > 1) {
|
|
52
|
-
newRootNodes.push(...item.children.slice(1));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
currentListItems.push(item);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
// Flush remaining
|
|
60
|
-
if (currentListItems.length > 0) {
|
|
61
|
-
newRootNodes.push({
|
|
62
|
-
type: 'list',
|
|
63
|
-
ordered: false,
|
|
64
|
-
children: [...currentListItems]
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
if (newRootNodes.length > 0) {
|
|
68
|
-
// If we performed any transformation (i.e., we found at least one heading)
|
|
69
|
-
const hasHeadings = newRootNodes.some(n => n.type === 'heading');
|
|
70
|
-
if (hasHeadings) {
|
|
71
|
-
children.splice(i, 1, ...newRootNodes);
|
|
72
|
-
i += newRootNodes.length - 1;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
16
|
+
const transformations = [];
|
|
17
|
+
// First pass: identify bullets that should become headings
|
|
18
|
+
visit(tree, 'list', (node, index, parent) => {
|
|
19
|
+
if (!parent || node.ordered)
|
|
20
|
+
return; // Only unordered lists
|
|
21
|
+
// Don't transform if there are no section bullets
|
|
22
|
+
// This preserves normal list behavior
|
|
23
|
+
if (transformations.length === 0) {
|
|
24
|
+
return tree;
|
|
75
25
|
}
|
|
76
|
-
|
|
26
|
+
// For now, just mark them for detection
|
|
27
|
+
// The actual transformation happens in the parser
|
|
28
|
+
return tree;
|
|
29
|
+
});
|
|
77
30
|
};
|
|
78
31
|
}
|
|
32
|
+
function isSectionBullet(listItem) {
|
|
33
|
+
if (!listItem.children || listItem.children.length === 0) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const firstChild = listItem.children[0];
|
|
37
|
+
const text = toString(firstChild).toLowerCase();
|
|
38
|
+
// Check for section indicators
|
|
39
|
+
const hasKeyword = SECTION_KEYWORDS.some(kw => text.includes(kw));
|
|
40
|
+
const hasColon = text.includes(':');
|
|
41
|
+
const hasContent = listItem.children.length > 1;
|
|
42
|
+
const isCapitalized = /^[A-Z]/.test(text);
|
|
43
|
+
const isLong = text.length > 30;
|
|
44
|
+
// It's likely a section if it has multiple indicators
|
|
45
|
+
const indicators = [hasKeyword, hasColon, hasContent, isCapitalized, isLong];
|
|
46
|
+
const score = indicators.filter(Boolean).length;
|
|
47
|
+
return score >= 2;
|
|
48
|
+
}
|
|
79
49
|
//# sourceMappingURL=bullet-sections.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bullet-sections.js","sourceRoot":"","sources":["../../src/plugins/bullet-sections.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bullet-sections.js","sourceRoot":"","sources":["../../src/plugins/bullet-sections.ts"],"names":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