flex-md 4.2.2 → 4.2.6
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/extract/extract.js +2 -1
- package/dist/md/parse.d.ts +4 -1
- package/dist/md/parse.js +18 -4
- package/dist/ofs/adapter.js +2 -1
- package/package.json +2 -2
package/dist/extract/extract.js
CHANGED
|
@@ -21,7 +21,8 @@ export function extractFromMarkdown(md, spec) {
|
|
|
21
21
|
workingContent = content;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
const
|
|
24
|
+
const bulletNames = spec.sections.map(s => s.name);
|
|
25
|
+
const parsed = parseHeadingsAndSections(workingContent, { bulletNames });
|
|
25
26
|
const sectionsByName = {};
|
|
26
27
|
const tables = [];
|
|
27
28
|
const specMap = new Map(spec.sections.map(s => [normalizeName(s.name), s]));
|
package/dist/md/parse.d.ts
CHANGED
|
@@ -24,7 +24,10 @@ export interface ParsedSection {
|
|
|
24
24
|
bodyEnd: number;
|
|
25
25
|
body: string;
|
|
26
26
|
}
|
|
27
|
-
export
|
|
27
|
+
export interface ParseHeadingsOptions {
|
|
28
|
+
bulletNames?: string[];
|
|
29
|
+
}
|
|
30
|
+
export declare function parseHeadingsAndSections(md: string, options?: ParseHeadingsOptions): ParsedSection[];
|
|
28
31
|
export declare function extractBullets(body: string): string[];
|
|
29
32
|
export declare function parseMarkdownTable(body: string, columns: string[]): Record<string, string>[];
|
|
30
33
|
export declare function isIssuesEnvelopeCheck(md: string): IssuesEnvelope;
|
package/dist/md/parse.js
CHANGED
|
@@ -28,12 +28,12 @@ export function extractFencedBlocks(text) {
|
|
|
28
28
|
}
|
|
29
29
|
return blocks;
|
|
30
30
|
}
|
|
31
|
-
export function parseHeadingsAndSections(md) {
|
|
31
|
+
export function parseHeadingsAndSections(md, options = {}) {
|
|
32
32
|
// Standard headings #... and alternative ===key.
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
const rx = /^((?:#{1,6})[ \t]+(.+?)[ \t]*|===(.+?)[ \t]*)$/gm;
|
|
33
|
+
// Also optionally allow "- Section" if specified in bulletNames.
|
|
34
|
+
const rx = /^((?:#{1,6})[ \t]+(.+?)[ \t]*|===(.+?)[ \t]*|([-*+])[ \t]+(.+?)[ \t]*)$/gm;
|
|
36
35
|
const headings = [];
|
|
36
|
+
const bulletNamesNormal = new Set((options.bulletNames || []).map(normalizeName));
|
|
37
37
|
let m;
|
|
38
38
|
while ((m = rx.exec(md)) !== null) {
|
|
39
39
|
const full = m[1] ?? "";
|
|
@@ -43,6 +43,20 @@ export function parseHeadingsAndSections(md) {
|
|
|
43
43
|
level = 1; // Treat ===key as a top-level heading
|
|
44
44
|
name = (m[3] ?? "").trim();
|
|
45
45
|
}
|
|
46
|
+
else if (m[4]) {
|
|
47
|
+
// It's a bullet (- / * / +)
|
|
48
|
+
const bulletChar = m[4];
|
|
49
|
+
const bulletText = (m[5] ?? "").trim();
|
|
50
|
+
const norm = normalizeName(bulletText);
|
|
51
|
+
if (bulletNamesNormal.has(norm)) {
|
|
52
|
+
level = 1;
|
|
53
|
+
name = bulletText;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// Not a recognized section header bullet, ignore it
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
46
60
|
else {
|
|
47
61
|
const hashesMatch = full.match(/^#+/);
|
|
48
62
|
const hashes = hashesMatch ? hashesMatch[0] : "";
|
package/dist/ofs/adapter.js
CHANGED
|
@@ -64,7 +64,8 @@ export function transformWithOfs(md, specOrRecallId) {
|
|
|
64
64
|
spec = specOrRecallId;
|
|
65
65
|
}
|
|
66
66
|
// 1. Parse sections using Flex-MD parser
|
|
67
|
-
const
|
|
67
|
+
const bulletNames = spec.sections.map(s => s.name);
|
|
68
|
+
const parsedSections = parseHeadingsAndSections(md, { bulletNames });
|
|
68
69
|
const parsedObj = {};
|
|
69
70
|
// 2. Map sections to OFS and apply complex parsing (tables/lists)
|
|
70
71
|
for (const sectionSpec of spec.sections) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flex-md",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.6",
|
|
4
4
|
"description": "Parse and stringify FlexMD: semi-structured Markdown with three powerful layers - Frames, Output Format Spec (OFS), and Detection/Extraction.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "",
|
|
@@ -50,6 +50,6 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"nd": "^1.2.0",
|
|
52
52
|
"nx-helpers": "^1.5.0",
|
|
53
|
-
"nx-md-parser": "^
|
|
53
|
+
"nx-md-parser": "^2.0.1"
|
|
54
54
|
}
|
|
55
55
|
}
|