flex-md 4.0.0 → 4.1.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/md/parse.d.ts +1 -0
- package/dist/md/parse.js +12 -0
- package/package.json +5 -2
package/dist/md/parse.d.ts
CHANGED
|
@@ -27,3 +27,4 @@ export interface ParsedSection {
|
|
|
27
27
|
export declare function parseHeadingsAndSections(md: string): ParsedSection[];
|
|
28
28
|
export declare function extractBullets(body: string): string[];
|
|
29
29
|
export declare function isIssuesEnvelopeCheck(md: string): IssuesEnvelope;
|
|
30
|
+
export declare function markdownToJson(md: string): Record<string, any>;
|
package/dist/md/parse.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toCamelCase } from "nx-helpers";
|
|
1
2
|
export function normalizeName(s) {
|
|
2
3
|
return s.trim().replace(/\s+/g, " ").toLowerCase();
|
|
3
4
|
}
|
|
@@ -114,3 +115,14 @@ export function isIssuesEnvelopeCheck(md) {
|
|
|
114
115
|
}
|
|
115
116
|
return { isIssuesEnvelope: ok, sections };
|
|
116
117
|
}
|
|
118
|
+
export function markdownToJson(md) {
|
|
119
|
+
// Robustly handle both actual newlines and literal \n (common in LLM JSON outputs)
|
|
120
|
+
const normalizedMd = (md || "").replace(/\\n/g, "\n");
|
|
121
|
+
const sections = parseHeadingsAndSections(normalizedMd);
|
|
122
|
+
const result = {};
|
|
123
|
+
for (const sec of sections) {
|
|
124
|
+
const key = toCamelCase(sec.heading.name);
|
|
125
|
+
result[key] = sec.body.trim();
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flex-md",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
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": "",
|
|
@@ -46,5 +46,8 @@
|
|
|
46
46
|
"@types/node": "^25.0.3",
|
|
47
47
|
"typescript": "^5.6.3",
|
|
48
48
|
"vitest": "^4.0.16"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"nx-helpers": "^1.5.0"
|
|
49
52
|
}
|
|
50
|
-
}
|
|
53
|
+
}
|