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.
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Detect if bullets should be treated as array items or sections
3
+ */
4
+ import { visit } from 'unist-util-visit';
5
+ import { toString } from 'mdast-util-to-string';
6
+ const SECTION_KEYWORDS = [
7
+ 'answer', 'summary', 'introduction', 'conclusion', 'overview',
8
+ 'assumptions', 'unknowns', 'evidence', 'notes', 'details',
9
+ 'description', 'background', 'analysis', 'findings', 'recommendations',
10
+ 'data', 'identity', 'network', 'security', 'monitoring', 'governance',
11
+ 'availability', 'backup', 'patch', 'operational', 'provider',
12
+ 'short', 'full', 'long' // Added common answer prefixes
13
+ ];
14
+ export function detectBulletMode(tree) {
15
+ const reasons = [];
16
+ let sectionScore = 0;
17
+ let arrayScore = 0;
18
+ let bulletCount = 0;
19
+ let bulletsWithContent = 0;
20
+ let bulletsWithColons = 0;
21
+ let bulletsWithNestedLists = 0;
22
+ let bulletsWithKeywords = 0;
23
+ let totalBulletLength = 0;
24
+ let rootLevelBullets = 0;
25
+ // Analyze the tree structure
26
+ visit(tree, 'list', (listNode, index, parent) => {
27
+ // Only analyze root-level lists or lists directly under root
28
+ const isRootLevel = parent?.type === 'root';
29
+ if (!isRootLevel)
30
+ return;
31
+ rootLevelBullets += listNode.children.length;
32
+ for (const listItem of listNode.children) {
33
+ bulletCount++;
34
+ // Get the text of this list item (first paragraph/text only)
35
+ const firstChild = listItem.children[0];
36
+ const itemText = firstChild ? toString(firstChild) : '';
37
+ totalBulletLength += itemText.length;
38
+ // 1. Check for colons (title pattern: "Short answer:" or "Data protection:")
39
+ if (itemText.includes(':')) {
40
+ bulletsWithColons++;
41
+ }
42
+ // 2. Check for content after the bullet (paragraphs, nested items)
43
+ if (listItem.children.length > 1) {
44
+ bulletsWithContent++;
45
+ }
46
+ // 3. Check for nested lists
47
+ const hasNestedList = listItem.children.some((child) => child.type === 'list');
48
+ if (hasNestedList) {
49
+ bulletsWithNestedLists++;
50
+ }
51
+ // 4. Check for section keywords
52
+ const lowerText = itemText.toLowerCase();
53
+ if (SECTION_KEYWORDS.some(kw => lowerText.includes(kw))) {
54
+ bulletsWithKeywords++;
55
+ }
56
+ }
57
+ });
58
+ if (bulletCount === 0) {
59
+ return {
60
+ mode: 'array',
61
+ confidence: 0,
62
+ reasons: ['No bullets found']
63
+ };
64
+ }
65
+ const avgLength = totalBulletLength / bulletCount;
66
+ // === SCORING FOR SECTIONS MODE ===
67
+ if (bulletsWithColons > 0) {
68
+ const percent = (bulletsWithColons / bulletCount * 100).toFixed(0);
69
+ sectionScore += 3;
70
+ reasons.push(`${bulletsWithColons}/${bulletCount} bullets have colons (${percent}%) - strong section indicator`);
71
+ }
72
+ if (bulletsWithContent > 0) {
73
+ const percent = (bulletsWithContent / bulletCount * 100).toFixed(0);
74
+ sectionScore += 3;
75
+ reasons.push(`${bulletsWithContent}/${bulletCount} bullets have content below (${percent}%) - strong section indicator`);
76
+ }
77
+ if (bulletsWithNestedLists > 0) {
78
+ sectionScore += 2;
79
+ reasons.push(`${bulletsWithNestedLists} bullets have nested lists - section indicator`);
80
+ }
81
+ if (bulletsWithKeywords > 0) {
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`);
85
+ }
86
+ if (avgLength > 30) {
87
+ sectionScore += 1;
88
+ reasons.push(`Long bullet text (avg ${avgLength.toFixed(0)} chars) - suggests titles`);
89
+ }
90
+ if (bulletCount <= 5 && (bulletsWithContent > 0 || bulletsWithColons > 0)) {
91
+ sectionScore += 1;
92
+ reasons.push('Few bullets with rich content suggests sections');
93
+ }
94
+ // === SCORING FOR ARRAY MODE ===
95
+ if (bulletsWithColons === 0 && bulletsWithContent === 0 && bulletsWithNestedLists === 0 && bulletsWithKeywords === 0) {
96
+ // Only if NO keywords are found
97
+ arrayScore += 4;
98
+ reasons.push('No bullets have content, colons, nesting, OR keywords - pure list indicator');
99
+ }
100
+ if (avgLength < 30) {
101
+ arrayScore += 2;
102
+ reasons.push(`Short bullet text (avg ${avgLength.toFixed(0)} chars) - suggests list items`);
103
+ }
104
+ if (bulletCount >= 3 && bulletsWithContent === 0) {
105
+ arrayScore += 2;
106
+ reasons.push(`${bulletCount} simple bullets without content - array pattern`);
107
+ }
108
+ if (bulletsWithKeywords === 0) {
109
+ arrayScore += 1;
110
+ reasons.push('No section keywords found');
111
+ }
112
+ // Edge case: all bullets are very short and no special features
113
+ if (avgLength < 20 && bulletsWithContent === 0 && bulletsWithColons === 0) {
114
+ arrayScore += 2;
115
+ reasons.push('Very short bullets with no features - definitely array');
116
+ }
117
+ // === DECISION ===
118
+ const totalScore = sectionScore + arrayScore;
119
+ const mode = sectionScore > arrayScore ? 'sections' : 'array';
120
+ const confidence = totalScore > 0 ? Math.abs(sectionScore - arrayScore) / totalScore : 0;
121
+ // Format reasons (top 5)
122
+ const topReasons = reasons.slice(0, 5);
123
+ return {
124
+ mode,
125
+ confidence,
126
+ reasons: topReasons
127
+ };
128
+ }
129
+ //# sourceMappingURL=detect-bullet-mode.js.map
@@ -0,0 +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;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,EAAE,SAAS,EAAE,UAAU,EAAE,YAA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ONS = "sections",
9
+ AUTO = "auto"
10
+ }
11
+ export interface RemarkParserOptions {
12
+ bulletMode?: BulletMode;
13
+ sectionKeywords?: string[];
14
+ debug?: boolean;
15
+ }
16
+ export declare class RemarkMarkdownParser {
17
+ private processor;
18
+ private options;
19
+ constructor(options?: RemarkParserOptions);
20
+ /**
21
+ * Parse markdown into sections
22
+ */
23
+ parseSections(markdown: string): MarkdownSection[];
24
+ /**
25
+ * Parse content (tables, lists, text)
26
+ */
27
+ parseContent(content: string): any;
28
+ /**
29
+ * Convert sections to object
30
+ */
31
+ sectionsToObject(sections: MarkdownSection[]): Record<string, any>;
32
+ private detectBulletMode;
33
+ private parseHeadingMode;
34
+ private parseSectionsMode;
35
+ private listItemToSection;
36
+ private parseTable;
37
+ private parseList;
38
+ private nodeToString;
39
+ private getDefaultKeywords;
40
+ }
41
+ //# sourceMappingURL=remark-markdown-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remark-markdown-parser.d.ts","sourceRoot":"","sources":["../src/remark-markdown-parser.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,oBAAY,UAAU;IACpB,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,IAAI,SAAS;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,OAAO,CAAgC;gBAEnC,OAAO,GAAE,mBAAwB;IAY7C;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,EAAE;IAmBlD;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG;IA2ClC;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAelE,OAAO,CAAC,gBAAgB;IA8DxB,OAAO,CAAC,gBAAgB;IAmCxB,OAAO,CAAC,iBAAiB;IAmCzB,OAAO,CAAC,iBAAiB;IA0BzB,OAAO,CAAC,UAAU;IAqBlB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,kBAAkB;CAS3B"}
@@ -0,0 +1,294 @@
1
+ /**
2
+ * Remark-based Markdown Parser
3
+ * Replaces regex-based parsing with AST-based parsing using unified/remark
4
+ */
5
+ import { unified } from 'unified';
6
+ import remarkParse from 'remark-parse';
7
+ import remarkGfm from 'remark-gfm';
8
+ import { visit } from 'unist-util-visit';
9
+ import { toString } from 'mdast-util-to-string';
10
+ import { toCamelCase } from 'nx-helpers';
11
+ export var BulletMode;
12
+ (function (BulletMode) {
13
+ BulletMode["ARRAY"] = "array";
14
+ BulletMode["SECTIONS"] = "sections";
15
+ BulletMode["AUTO"] = "auto";
16
+ })(BulletMode || (BulletMode = {}));
17
+ export class RemarkMarkdownParser {
18
+ processor;
19
+ options;
20
+ constructor(options = {}) {
21
+ this.processor = unified()
22
+ .use(remarkParse)
23
+ .use(remarkGfm);
24
+ this.options = {
25
+ bulletMode: options.bulletMode || BulletMode.AUTO,
26
+ sectionKeywords: options.sectionKeywords || this.getDefaultKeywords(),
27
+ debug: options.debug || false
28
+ };
29
+ }
30
+ /**
31
+ * Parse markdown into sections
32
+ */
33
+ parseSections(markdown) {
34
+ const tree = this.processor.parse(markdown);
35
+ // Detect bullet mode if AUTO
36
+ const bulletMode = this.options.bulletMode === BulletMode.AUTO
37
+ ? this.detectBulletMode(tree)
38
+ : this.options.bulletMode;
39
+ if (this.options.debug) {
40
+ console.log(`📋 Bullet mode: ${bulletMode}`);
41
+ }
42
+ if (bulletMode === BulletMode.SECTIONS) {
43
+ return this.parseSectionsMode(tree, markdown);
44
+ }
45
+ else {
46
+ return this.parseHeadingMode(tree);
47
+ }
48
+ }
49
+ /**
50
+ * Parse content (tables, lists, text)
51
+ */
52
+ parseContent(content) {
53
+ const trimmed = content.trim();
54
+ if (!trimmed)
55
+ return '';
56
+ const tree = this.processor.parse(trimmed);
57
+ // Single node - return specific type
58
+ if (tree.children.length === 1) {
59
+ const child = tree.children[0];
60
+ if (child.type === 'table') {
61
+ return this.parseTable(child);
62
+ }
63
+ if (child.type === 'list') {
64
+ return this.parseList(child);
65
+ }
66
+ if (child.type === 'paragraph') {
67
+ return toString(child);
68
+ }
69
+ }
70
+ // Multiple children - combine
71
+ const results = [];
72
+ for (const child of tree.children) {
73
+ if (child.type === 'table') {
74
+ return this.parseTable(child); // Single table dominates
75
+ }
76
+ else if (child.type === 'list') {
77
+ return this.parseList(child); // Single list dominates
78
+ }
79
+ else if (child.type === 'paragraph') {
80
+ results.push(toString(child));
81
+ }
82
+ else {
83
+ results.push(toString(child));
84
+ }
85
+ }
86
+ // Join text results
87
+ const text = results.join('\n\n').trim();
88
+ return text || trimmed;
89
+ }
90
+ /**
91
+ * Convert sections to object
92
+ */
93
+ sectionsToObject(sections) {
94
+ const result = {};
95
+ for (const section of sections) {
96
+ const key = toCamelCase(section.heading);
97
+ result[key] = this.parseContent(section.content);
98
+ }
99
+ return result;
100
+ }
101
+ // ========================================================================
102
+ // PRIVATE METHODS - Mode Detection
103
+ // ========================================================================
104
+ detectBulletMode(tree) {
105
+ let bulletCount = 0;
106
+ let bulletsWithContent = 0;
107
+ let bulletsWithColons = 0;
108
+ let bulletsWithNestedLists = 0;
109
+ let bulletsWithKeywords = 0;
110
+ let totalLength = 0;
111
+ visit(tree, 'list', (listNode, index, parent) => {
112
+ // Only analyze root-level lists
113
+ if (!parent || parent.type !== 'root')
114
+ return;
115
+ for (const listItem of listNode.children) {
116
+ bulletCount++;
117
+ const firstChild = listItem.children[0];
118
+ const text = firstChild ? toString(firstChild) : '';
119
+ totalLength += text.length;
120
+ // Check indicators
121
+ if (text.includes(':'))
122
+ bulletsWithColons++;
123
+ if (listItem.children.length > 1)
124
+ bulletsWithContent++;
125
+ const hasNestedList = listItem.children.some((c) => c.type === 'list');
126
+ if (hasNestedList)
127
+ bulletsWithNestedLists++;
128
+ const lowerText = text.toLowerCase();
129
+ if (this.options.sectionKeywords.some(kw => lowerText.includes(kw))) {
130
+ bulletsWithKeywords++;
131
+ }
132
+ }
133
+ });
134
+ if (bulletCount === 0)
135
+ return BulletMode.ARRAY;
136
+ const avgLength = totalLength / bulletCount;
137
+ // Scoring
138
+ let sectionScore = 0;
139
+ let arrayScore = 0;
140
+ if (bulletsWithColons > 0)
141
+ sectionScore += 3;
142
+ if (bulletsWithContent > 0)
143
+ sectionScore += 3;
144
+ if (bulletsWithNestedLists > 0)
145
+ sectionScore += 2;
146
+ if (bulletsWithKeywords > 0)
147
+ sectionScore += 2;
148
+ if (avgLength > 30)
149
+ sectionScore += 1;
150
+ if (bulletsWithContent === 0 && bulletsWithColons === 0)
151
+ arrayScore += 4;
152
+ if (avgLength < 30)
153
+ arrayScore += 2;
154
+ if (bulletCount >= 3 && bulletsWithContent === 0)
155
+ arrayScore += 2;
156
+ if (this.options.debug) {
157
+ console.log(`🔍 Detection scores - Sections: ${sectionScore}, Array: ${arrayScore}`);
158
+ }
159
+ return sectionScore > arrayScore ? BulletMode.SECTIONS : BulletMode.ARRAY;
160
+ }
161
+ // ========================================================================
162
+ // PRIVATE METHODS - Parsing Modes
163
+ // ========================================================================
164
+ parseHeadingMode(tree) {
165
+ const sections = [];
166
+ let currentSection = null;
167
+ let currentContent = [];
168
+ for (const node of tree.children) {
169
+ if (node.type === 'heading') {
170
+ // Save previous section
171
+ if (currentSection) {
172
+ currentSection.content = currentContent.join('\n\n').trim();
173
+ sections.push(currentSection);
174
+ }
175
+ // Start new section
176
+ currentSection = {
177
+ heading: toString(node),
178
+ content: '',
179
+ level: node.depth
180
+ };
181
+ currentContent = [];
182
+ }
183
+ else if (currentSection) {
184
+ // Add to current section content
185
+ currentContent.push(this.nodeToString(node));
186
+ }
187
+ }
188
+ // Save last section
189
+ if (currentSection) {
190
+ currentSection.content = currentContent.join('\n\n').trim();
191
+ sections.push(currentSection);
192
+ }
193
+ return sections;
194
+ }
195
+ parseSectionsMode(tree, markdown) {
196
+ const sections = [];
197
+ let inList = false;
198
+ for (const node of tree.children) {
199
+ if (node.type === 'heading') {
200
+ // Regular heading
201
+ const heading = toString(node);
202
+ const content = ''; // Will be filled by next nodes
203
+ sections.push({
204
+ heading,
205
+ content,
206
+ level: node.depth
207
+ });
208
+ }
209
+ else if (node.type === 'list') {
210
+ // Process each list item as a section
211
+ for (const listItem of node.children) {
212
+ const section = this.listItemToSection(listItem);
213
+ if (section) {
214
+ sections.push(section);
215
+ }
216
+ }
217
+ }
218
+ else if (sections.length > 0) {
219
+ // Add content to last section
220
+ const lastSection = sections[sections.length - 1];
221
+ const nodeContent = this.nodeToString(node);
222
+ lastSection.content = lastSection.content
223
+ ? `${lastSection.content}\n\n${nodeContent}`
224
+ : nodeContent;
225
+ }
226
+ }
227
+ return sections;
228
+ }
229
+ listItemToSection(listItem) {
230
+ if (!listItem.children || listItem.children.length === 0) {
231
+ return null;
232
+ }
233
+ const firstChild = listItem.children[0];
234
+ const heading = toString(firstChild).replace(/:$/, ''); // Remove trailing colon
235
+ const contentNodes = listItem.children.slice(1);
236
+ let content = '';
237
+ if (contentNodes.length > 0) {
238
+ content = contentNodes.map((node) => this.nodeToString(node)).join('\n\n').trim();
239
+ }
240
+ return {
241
+ heading,
242
+ content,
243
+ level: 1
244
+ };
245
+ }
246
+ // ========================================================================
247
+ // PRIVATE METHODS - Content Parsing
248
+ // ========================================================================
249
+ parseTable(tableNode) {
250
+ const rows = tableNode.children;
251
+ if (rows.length === 0)
252
+ return [];
253
+ // First row = headers
254
+ const headerRow = rows[0];
255
+ const headers = headerRow.children.map((cell) => toCamelCase(toString(cell).trim()));
256
+ // Data rows
257
+ return rows.slice(1).map((row) => {
258
+ const obj = {};
259
+ row.children.forEach((cell, i) => {
260
+ const key = headers[i] || `column${i}`;
261
+ obj[key] = toString(cell).trim();
262
+ });
263
+ return obj;
264
+ });
265
+ }
266
+ parseList(listNode) {
267
+ return listNode.children.map((item) => {
268
+ // Get first child only (ignore nested content for simple lists)
269
+ const firstChild = item.children[0];
270
+ return toString(firstChild).trim();
271
+ });
272
+ }
273
+ nodeToString(node) {
274
+ if (node.type === 'table') {
275
+ // Return markdown representation or JSON
276
+ return JSON.stringify(this.parseTable(node));
277
+ }
278
+ if (node.type === 'list') {
279
+ // Return as list
280
+ return this.parseList(node).map(item => `- ${item}`).join('\n');
281
+ }
282
+ return toString(node);
283
+ }
284
+ getDefaultKeywords() {
285
+ return [
286
+ 'answer', 'summary', 'introduction', 'conclusion', 'overview',
287
+ 'assumptions', 'unknowns', 'evidence', 'notes', 'details',
288
+ 'description', 'background', 'analysis', 'findings', 'recommendations',
289
+ 'data', 'identity', 'network', 'security', 'monitoring', 'governance',
290
+ 'availability', 'backup', 'patch', 'operational', 'provider'
291
+ ];
292
+ }
293
+ }
294
+ //# sourceMappingURL=remark-markdown-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remark-markdown-parser.js","sourceRoot":"","sources":["../src/remark-markdown-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAQzC,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,mCAAqB,CAAA;IACrB,2BAAa,CAA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CAAC,CAAC,CAAC;QAC/C,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACzB,iBAAiB;YACjB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAEO,kBAAkB;QACxB,OAAO;YACL,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU;YAC7D,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS;YACzD,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB;YACtE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY;YACrE,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU;SAC7D,CAAC;IACJ,CAAC;CACF"}
package/dist/types.d.ts CHANGED
@@ -1,11 +1,25 @@
1
+ export declare enum BulletMode {
2
+ ARRAY = "array",
3
+ SECTIONS = "sections",
4
+ AUTO = "auto"
5
+ }
1
6
  export interface MarkdownSection {
2
7
  heading: string;
3
8
  content: any;
4
9
  level: number;
5
- format: 'heading' | 'list' | 'table' | 'text';
10
+ format?: 'heading' | 'bullet' | 'text';
11
+ }
12
+ export interface ParserOptions {
13
+ bulletMode?: BulletMode;
14
+ debug?: boolean;
15
+ }
16
+ export interface BulletModeResult {
17
+ mode: 'array' | 'sections';
18
+ confidence: number;
19
+ reasons: string[];
6
20
  }
7
- export type ParseResult = Record<string, any>;
8
- export interface OutputFormatSpec {
21
+ export interface ParseResult {
22
+ sections?: MarkdownSection[];
9
23
  [key: string]: any;
10
24
  }
11
25
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;CAC/C;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAE/B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU;IACpB,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,IAAI,SAAS;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAGD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"}
package/dist/types.js CHANGED
@@ -1,2 +1,7 @@
1
- export {};
1
+ export var BulletMode;
2
+ (function (BulletMode) {
3
+ BulletMode["ARRAY"] = "array";
4
+ BulletMode["SECTIONS"] = "sections";
5
+ BulletMode["AUTO"] = "auto";
6
+ })(BulletMode || (BulletMode = {}));
2
7
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,mCAAqB,CAAA;IACrB,2BAAa,CAAA;AACf,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx-json-parser",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Transform strings to JSON based on Markdown structure using unified/remark",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './types.js';
2
2
  export * from './parser.js';
3
3
  export * from './transformer.js';
4
+ export * from './plugins/bullet-sections.js';
4
5
 
5
6
  import { JSONTransformer } from './transformer.js';
6
7