@docubook/core 1.7.2 → 1.8.1
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/README.md +25 -1
- package/dist/chunk-HZJLRYAI.js +45 -0
- package/dist/chunk-HZJLRYAI.js.map +1 -0
- package/dist/index.d.ts +118 -10
- package/dist/index.js +514 -6
- package/dist/index.js.map +1 -1
- package/dist/utils.d.ts +12 -10
- package/dist/utils.js +16 -38
- package/dist/utils.js.map +1 -1
- package/package.json +5 -3
- package/dist/__tests__/compile.test.d.ts +0 -2
- package/dist/__tests__/compile.test.d.ts.map +0 -1
- package/dist/__tests__/compile.test.js +0 -122
- package/dist/__tests__/compile.test.js.map +0 -1
- package/dist/__tests__/content.test.d.ts +0 -2
- package/dist/__tests__/content.test.d.ts.map +0 -1
- package/dist/__tests__/content.test.js +0 -109
- package/dist/__tests__/content.test.js.map +0 -1
- package/dist/__tests__/extract.test.d.ts +0 -2
- package/dist/__tests__/extract.test.d.ts.map +0 -1
- package/dist/__tests__/extract.test.js +0 -95
- package/dist/__tests__/extract.test.js.map +0 -1
- package/dist/__tests__/plugins/handleCodeExpandable.test.d.ts +0 -2
- package/dist/__tests__/plugins/handleCodeExpandable.test.d.ts.map +0 -1
- package/dist/__tests__/plugins/handleCodeExpandable.test.js +0 -191
- package/dist/__tests__/plugins/handleCodeExpandable.test.js.map +0 -1
- package/dist/__tests__/plugins/handleCodeTitles.test.d.ts +0 -2
- package/dist/__tests__/plugins/handleCodeTitles.test.d.ts.map +0 -1
- package/dist/__tests__/plugins/handleCodeTitles.test.js +0 -99
- package/dist/__tests__/plugins/handleCodeTitles.test.js.map +0 -1
- package/dist/compile.d.ts +0 -28
- package/dist/compile.d.ts.map +0 -1
- package/dist/compile.js +0 -88
- package/dist/compile.js.map +0 -1
- package/dist/content.d.ts +0 -52
- package/dist/content.d.ts.map +0 -1
- package/dist/content.js +0 -102
- package/dist/content.js.map +0 -1
- package/dist/extract.d.ts +0 -13
- package/dist/extract.d.ts.map +0 -1
- package/dist/extract.js +0 -96
- package/dist/extract.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/plugins/handleCodeExpandable.d.ts +0 -4
- package/dist/plugins/handleCodeExpandable.d.ts.map +0 -1
- package/dist/plugins/handleCodeExpandable.js +0 -174
- package/dist/plugins/handleCodeExpandable.js.map +0 -1
- package/dist/plugins/handleCodeTitles.d.ts +0 -3
- package/dist/plugins/handleCodeTitles.d.ts.map +0 -1
- package/dist/plugins/handleCodeTitles.js +0 -38
- package/dist/plugins/handleCodeTitles.js.map +0 -1
- package/dist/types.d.ts +0 -12
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts.map +0 -1
package/dist/utils.js
CHANGED
|
@@ -1,39 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export function formatDate(dateStrOrDate) {
|
|
18
|
-
const date = stringToDate(dateStrOrDate);
|
|
19
|
-
return date.toLocaleDateString("en-US", {
|
|
20
|
-
weekday: "long",
|
|
21
|
-
year: "numeric",
|
|
22
|
-
month: "long",
|
|
23
|
-
day: "numeric",
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
/** Format date to short format (e.g. "Apr 5, 2026") */
|
|
27
|
-
export function formatDate2(dateStrOrDate) {
|
|
28
|
-
const date = stringToDate(dateStrOrDate);
|
|
29
|
-
return date.toLocaleDateString("en-US", {
|
|
30
|
-
month: "short",
|
|
31
|
-
day: "numeric",
|
|
32
|
-
year: "numeric",
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
export function toIsoDateOnly(dateStrOrDate) {
|
|
36
|
-
const date = stringToDate(dateStrOrDate);
|
|
37
|
-
return date.toISOString().slice(0, 10);
|
|
38
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
cn,
|
|
3
|
+
formatDate,
|
|
4
|
+
formatDate2,
|
|
5
|
+
parseDate,
|
|
6
|
+
stringToDate,
|
|
7
|
+
toIsoDateOnly
|
|
8
|
+
} from "./chunk-HZJLRYAI.js";
|
|
9
|
+
export {
|
|
10
|
+
cn,
|
|
11
|
+
formatDate,
|
|
12
|
+
formatDate2,
|
|
13
|
+
parseDate,
|
|
14
|
+
stringToDate,
|
|
15
|
+
toIsoDateOnly
|
|
16
|
+
};
|
|
39
17
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docubook/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "Shared MDX compile pipeline and markdown utilities for DocuBook",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -54,12 +54,14 @@
|
|
|
54
54
|
"@types/node": "^20.19.37",
|
|
55
55
|
"@types/react": "19.2.17",
|
|
56
56
|
"@types/unist": "^3.0.3",
|
|
57
|
-
"
|
|
57
|
+
"tsup": "^8.5.1",
|
|
58
|
+
"typescript": "^5.9.3",
|
|
58
59
|
"unified": "^11.0.0"
|
|
59
60
|
},
|
|
60
61
|
"scripts": {
|
|
61
|
-
"build": "
|
|
62
|
+
"build": "tsup",
|
|
62
63
|
"test": "vitest run",
|
|
64
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
63
65
|
"clean": "rm -rf dist"
|
|
64
66
|
}
|
|
65
67
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compile.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/compile.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { preProcess, postProcess, createDefaultRehypePlugins, createDefaultRemarkPlugins, parseMdx, } from "../compile";
|
|
3
|
-
function buildPreTree(lang, code) {
|
|
4
|
-
return {
|
|
5
|
-
type: "element",
|
|
6
|
-
tagName: "pre",
|
|
7
|
-
properties: {},
|
|
8
|
-
children: [
|
|
9
|
-
{
|
|
10
|
-
type: "element",
|
|
11
|
-
tagName: "code",
|
|
12
|
-
properties: { className: [`language-${lang}`] },
|
|
13
|
-
children: [{ type: "text", value: code }],
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
describe("preProcess", () => {
|
|
19
|
-
it("extracts raw code and language from pre>code", () => {
|
|
20
|
-
const tree = buildPreTree("typescript", "const x = 1");
|
|
21
|
-
preProcess()(tree);
|
|
22
|
-
const el = tree;
|
|
23
|
-
expect(el.raw).toBe("const x = 1");
|
|
24
|
-
expect(el.language).toBe("typescript");
|
|
25
|
-
});
|
|
26
|
-
it("handles language with colon suffix (title)", () => {
|
|
27
|
-
const tree = buildPreTree("js:app.js", "console.log('hi')");
|
|
28
|
-
preProcess()(tree);
|
|
29
|
-
const el = tree;
|
|
30
|
-
expect(el.language).toBe("js");
|
|
31
|
-
});
|
|
32
|
-
it("skips non-pre elements", () => {
|
|
33
|
-
const tree = {
|
|
34
|
-
type: "element",
|
|
35
|
-
tagName: "div",
|
|
36
|
-
properties: {},
|
|
37
|
-
children: [],
|
|
38
|
-
};
|
|
39
|
-
preProcess()(tree);
|
|
40
|
-
expect(tree.raw).toBeUndefined();
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
describe("postProcess", () => {
|
|
44
|
-
it("copies raw and language to properties", () => {
|
|
45
|
-
const tree = {
|
|
46
|
-
type: "element",
|
|
47
|
-
tagName: "pre",
|
|
48
|
-
properties: {},
|
|
49
|
-
raw: "const x = 1",
|
|
50
|
-
language: "ts",
|
|
51
|
-
codeTitle: "example.ts",
|
|
52
|
-
children: [],
|
|
53
|
-
};
|
|
54
|
-
postProcess()(tree);
|
|
55
|
-
const el = tree;
|
|
56
|
-
expect(el.properties?.raw).toBe("const x = 1");
|
|
57
|
-
expect(el.properties?.["data-language"]).toBe("ts");
|
|
58
|
-
expect(el.properties?.["data-title"]).toBe("example.ts");
|
|
59
|
-
});
|
|
60
|
-
it("does not overwrite existing data-language", () => {
|
|
61
|
-
const tree = {
|
|
62
|
-
type: "element",
|
|
63
|
-
tagName: "pre",
|
|
64
|
-
properties: { "data-language": "python" },
|
|
65
|
-
language: "ts",
|
|
66
|
-
children: [],
|
|
67
|
-
};
|
|
68
|
-
postProcess()(tree);
|
|
69
|
-
expect(tree.properties?.["data-language"]).toBe("python");
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
describe("createDefaultRehypePlugins", () => {
|
|
73
|
-
it("returns an array of plugins", () => {
|
|
74
|
-
const plugins = createDefaultRehypePlugins();
|
|
75
|
-
expect(Array.isArray(plugins)).toBe(true);
|
|
76
|
-
expect(plugins.length).toBeGreaterThan(0);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
describe("createDefaultRemarkPlugins", () => {
|
|
80
|
-
it("returns an array of plugins", () => {
|
|
81
|
-
const plugins = createDefaultRemarkPlugins();
|
|
82
|
-
expect(Array.isArray(plugins)).toBe(true);
|
|
83
|
-
expect(plugins.length).toBeGreaterThan(0);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
describe("parseMdx", () => {
|
|
87
|
-
it("compiles basic MDX with frontmatter", async () => {
|
|
88
|
-
const mdx = `---
|
|
89
|
-
title: Test
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## Hello World`;
|
|
93
|
-
const result = await parseMdx(mdx);
|
|
94
|
-
expect(result.frontmatter.title).toBe("Test");
|
|
95
|
-
expect(result.content).toBeDefined();
|
|
96
|
-
});
|
|
97
|
-
it("compiles MDX without frontmatter when disabled", async () => {
|
|
98
|
-
const mdx = `## Just Content`;
|
|
99
|
-
const result = await parseMdx(mdx, { parseFrontmatter: false });
|
|
100
|
-
expect(result.content).toBeDefined();
|
|
101
|
-
});
|
|
102
|
-
it("compiles code blocks with language", async () => {
|
|
103
|
-
const mdx = `---
|
|
104
|
-
title: Code
|
|
105
|
-
---
|
|
106
|
-
|
|
107
|
-
\`\`\`typescript
|
|
108
|
-
const x: number = 1
|
|
109
|
-
\`\`\``;
|
|
110
|
-
const result = await parseMdx(mdx);
|
|
111
|
-
expect(result.frontmatter.title).toBe("Code");
|
|
112
|
-
expect(result.content).toBeDefined();
|
|
113
|
-
});
|
|
114
|
-
it("applies GFM (tables)", async () => {
|
|
115
|
-
const mdx = `| A | B |
|
|
116
|
-
| - | - |
|
|
117
|
-
| 1 | 2 |`;
|
|
118
|
-
const result = await parseMdx(mdx, { parseFrontmatter: false });
|
|
119
|
-
expect(result.content).toBeDefined();
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
//# sourceMappingURL=compile.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compile.test.js","sourceRoot":"","sources":["../../src/__tests__/compile.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EACL,UAAU,EACV,WAAW,EACX,0BAA0B,EAC1B,0BAA0B,EAC1B,QAAQ,GACT,MAAM,YAAY,CAAC;AAGpB,SAAS,YAAY,CAAC,IAAY,EAAE,IAAY;IAC9C,OAAO;QACL,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,MAAM;gBACf,UAAU,EAAE,EAAE,SAAS,EAAE,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IAEH,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;QAClD,MAAM,GAAG,GAAG;;;;;;OAMT,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAoB,GAAG,CAAC,CAAC;QACtD,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,GAAG,GAAG;;UAEN,CAAC;QACP,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,GAAG,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,CAAC;QAChE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/content.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { readMdxFileBySlug, parseMdxFile, compileParsedMdxFile, createMdxContentService, } from "../content";
|
|
4
|
-
const FIXTURES_ROOT = path.resolve(__dirname, "__fixtures__");
|
|
5
|
-
describe("readMdxFileBySlug", () => {
|
|
6
|
-
it("reads flat slug (getting-started.mdx)", async () => {
|
|
7
|
-
const result = await readMdxFileBySlug("getting-started", {
|
|
8
|
-
rootDir: FIXTURES_ROOT,
|
|
9
|
-
});
|
|
10
|
-
expect(result.content).toContain("title: Getting Started");
|
|
11
|
-
expect(result.filePath).toBe("docs/getting-started.mdx");
|
|
12
|
-
});
|
|
13
|
-
it("reads nested slug via index.mdx (guide/index.mdx)", async () => {
|
|
14
|
-
const result = await readMdxFileBySlug("guide", {
|
|
15
|
-
rootDir: FIXTURES_ROOT,
|
|
16
|
-
});
|
|
17
|
-
expect(result.content).toContain("title: Guide Overview");
|
|
18
|
-
expect(result.filePath).toBe("docs/guide/index.mdx");
|
|
19
|
-
});
|
|
20
|
-
it("reads root slug as index.mdx", async () => {
|
|
21
|
-
const result = await readMdxFileBySlug("", {
|
|
22
|
-
rootDir: FIXTURES_ROOT,
|
|
23
|
-
});
|
|
24
|
-
expect(result.content).toContain("title: Home");
|
|
25
|
-
expect(result.filePath).toBe("docs/index.mdx");
|
|
26
|
-
});
|
|
27
|
-
it("throws on non-existent slug", async () => {
|
|
28
|
-
await expect(readMdxFileBySlug("does-not-exist", { rootDir: FIXTURES_ROOT })).rejects.toThrow("Could not find mdx file");
|
|
29
|
-
});
|
|
30
|
-
it("rejects path traversal attempts", async () => {
|
|
31
|
-
await expect(readMdxFileBySlug("../../etc/passwd", { rootDir: FIXTURES_ROOT })).rejects.toThrow("Could not find mdx file");
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
describe("parseMdxFile", () => {
|
|
35
|
-
it("extracts frontmatter and tocs", async () => {
|
|
36
|
-
const raw = await readMdxFileBySlug("getting-started", {
|
|
37
|
-
rootDir: FIXTURES_ROOT,
|
|
38
|
-
});
|
|
39
|
-
const parsed = parseMdxFile(raw);
|
|
40
|
-
expect(parsed.frontmatter.title).toBe("Getting Started");
|
|
41
|
-
expect(parsed.frontmatter.description).toBe("Quick start guide");
|
|
42
|
-
expect(parsed.tocs.length).toBeGreaterThan(0);
|
|
43
|
-
expect(parsed.tocs[0].text).toBe("Installation");
|
|
44
|
-
expect(parsed.tocs[0].href).toBe("#installation");
|
|
45
|
-
});
|
|
46
|
-
it("strips frontmatter from content", async () => {
|
|
47
|
-
const raw = await readMdxFileBySlug("getting-started", {
|
|
48
|
-
rootDir: FIXTURES_ROOT,
|
|
49
|
-
});
|
|
50
|
-
const parsed = parseMdxFile(raw);
|
|
51
|
-
expect(parsed.content).not.toContain("---");
|
|
52
|
-
expect(parsed.content).toContain("## Installation");
|
|
53
|
-
});
|
|
54
|
-
it("supports custom tocsExtractor", async () => {
|
|
55
|
-
const raw = await readMdxFileBySlug("getting-started", {
|
|
56
|
-
rootDir: FIXTURES_ROOT,
|
|
57
|
-
});
|
|
58
|
-
const parsed = parseMdxFile(raw, {
|
|
59
|
-
tocsExtractor: () => [{ level: 1, text: "Custom", href: "#custom" }],
|
|
60
|
-
});
|
|
61
|
-
expect(parsed.tocs).toEqual([{ level: 1, text: "Custom", href: "#custom" }]);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
describe("compileParsedMdxFile", () => {
|
|
65
|
-
it("compiles parsed MDX to React content", async () => {
|
|
66
|
-
const raw = await readMdxFileBySlug("getting-started", {
|
|
67
|
-
rootDir: FIXTURES_ROOT,
|
|
68
|
-
});
|
|
69
|
-
const parsed = parseMdxFile(raw);
|
|
70
|
-
const compiled = await compileParsedMdxFile(parsed);
|
|
71
|
-
expect(compiled.content).toBeDefined();
|
|
72
|
-
expect(compiled.frontmatter.title).toBe("Getting Started");
|
|
73
|
-
expect(compiled.tocs.length).toBeGreaterThan(0);
|
|
74
|
-
expect(compiled.filePath).toBe("docs/getting-started.mdx");
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
describe("createMdxContentService", () => {
|
|
78
|
-
const service = createMdxContentService({
|
|
79
|
-
readOptions: { rootDir: FIXTURES_ROOT },
|
|
80
|
-
});
|
|
81
|
-
it("getParsedForSlug returns parsed data", async () => {
|
|
82
|
-
const parsed = await service.getParsedForSlug("getting-started");
|
|
83
|
-
expect(parsed.frontmatter.title).toBe("Getting Started");
|
|
84
|
-
expect(parsed.tocs.length).toBeGreaterThan(0);
|
|
85
|
-
});
|
|
86
|
-
it("getFrontmatterForSlug returns frontmatter only", async () => {
|
|
87
|
-
const fm = await service.getFrontmatterForSlug("guide");
|
|
88
|
-
expect(fm.title).toBe("Guide Overview");
|
|
89
|
-
});
|
|
90
|
-
it("getTocsForSlug returns tocs only", async () => {
|
|
91
|
-
const tocs = await service.getTocsForSlug("getting-started");
|
|
92
|
-
expect(tocs[0].text).toBe("Installation");
|
|
93
|
-
expect(tocs[1].text).toBe("Usage");
|
|
94
|
-
});
|
|
95
|
-
it("getCompiledForSlug returns compiled result", async () => {
|
|
96
|
-
const compiled = await service.getCompiledForSlug("getting-started");
|
|
97
|
-
expect(compiled.content).toBeDefined();
|
|
98
|
-
expect(compiled.frontmatter.title).toBe("Getting Started");
|
|
99
|
-
});
|
|
100
|
-
it("supports frontmatterEnricher", async () => {
|
|
101
|
-
const enrichedService = createMdxContentService({
|
|
102
|
-
readOptions: { rootDir: FIXTURES_ROOT },
|
|
103
|
-
frontmatterEnricher: (fm) => ({ ...fm, enriched: true }),
|
|
104
|
-
});
|
|
105
|
-
const parsed = await enrichedService.getParsedForSlug("getting-started");
|
|
106
|
-
expect(parsed.frontmatter.enriched).toBe(true);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
//# sourceMappingURL=content.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content.test.js","sourceRoot":"","sources":["../../src/__tests__/content.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAEpB,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;AAE9D,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,EAAE;Y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AQ,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;QACrE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QACvC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,eAAe,GAAG,uBAAuB,CAAuC;YACpF,WAAW,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE;YACvC,mBAAmB,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;SACzD,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;QACzE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/extract.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { sluggify, extractTocsFromRawMdx, extractFrontmatter, extractFrontmatterWithContent, } from "../extract";
|
|
3
|
-
describe("sluggify", () => {
|
|
4
|
-
it("converts text to lowercase kebab-case", () => {
|
|
5
|
-
expect(sluggify("Hello World")).toBe("hello-world");
|
|
6
|
-
});
|
|
7
|
-
it("removes special characters", () => {
|
|
8
|
-
expect(sluggify("What's New?")).toBe("whats-new");
|
|
9
|
-
});
|
|
10
|
-
it("removes accents", () => {
|
|
11
|
-
expect(sluggify("Café Résumé")).toBe("cafe-resume");
|
|
12
|
-
});
|
|
13
|
-
it("handles multiple spaces", () => {
|
|
14
|
-
expect(sluggify("a b c")).toBe("a-b-c");
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
describe("extractTocsFromRawMdx", () => {
|
|
18
|
-
it("extracts h2 and h3 headings", () => {
|
|
19
|
-
const mdx = `## First\n### Second\n## Third`;
|
|
20
|
-
const tocs = extractTocsFromRawMdx(mdx);
|
|
21
|
-
expect(tocs).toEqual([
|
|
22
|
-
{ level: 2, text: "First", href: "#first" },
|
|
23
|
-
{ level: 3, text: "Second", href: "#second" },
|
|
24
|
-
{ level: 2, text: "Third", href: "#third" },
|
|
25
|
-
]);
|
|
26
|
-
});
|
|
27
|
-
it("ignores h1 headings", () => {
|
|
28
|
-
const mdx = `# Title\n## Section`;
|
|
29
|
-
const tocs = extractTocsFromRawMdx(mdx);
|
|
30
|
-
expect(tocs).toHaveLength(1);
|
|
31
|
-
expect(tocs[0].text).toBe("Section");
|
|
32
|
-
});
|
|
33
|
-
it("ignores headings inside fenced code blocks", () => {
|
|
34
|
-
const mdx = "```\n## Not a heading\n```\n## Real heading";
|
|
35
|
-
const tocs = extractTocsFromRawMdx(mdx);
|
|
36
|
-
expect(tocs).toHaveLength(1);
|
|
37
|
-
expect(tocs[0].text).toBe("Real heading");
|
|
38
|
-
});
|
|
39
|
-
it("handles 4-backtick fences", () => {
|
|
40
|
-
const mdx = "````\n## Inside\n````\n## Outside";
|
|
41
|
-
const tocs = extractTocsFromRawMdx(mdx);
|
|
42
|
-
expect(tocs).toHaveLength(1);
|
|
43
|
-
expect(tocs[0].text).toBe("Outside");
|
|
44
|
-
});
|
|
45
|
-
it("extracts Release component versions", () => {
|
|
46
|
-
const mdx = `<Release version="1.2.0">\nContent\n</Release>`;
|
|
47
|
-
const tocs = extractTocsFromRawMdx(mdx);
|
|
48
|
-
expect(tocs).toEqual([{ level: 2, text: "v1.2.0", href: "#1.2.0" }]);
|
|
49
|
-
});
|
|
50
|
-
it("returns empty array for content without headings", () => {
|
|
51
|
-
const tocs = extractTocsFromRawMdx("Just some text");
|
|
52
|
-
expect(tocs).toEqual([]);
|
|
53
|
-
});
|
|
54
|
-
it("strips trailing hashes from headings", () => {
|
|
55
|
-
const mdx = `## Heading ##`;
|
|
56
|
-
const tocs = extractTocsFromRawMdx(mdx);
|
|
57
|
-
expect(tocs[0].text).toBe("Heading");
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
describe("extractFrontmatter", () => {
|
|
61
|
-
it("extracts YAML frontmatter", () => {
|
|
62
|
-
const content = `---\ntitle: Hello\ndescription: World\n---\n# Content`;
|
|
63
|
-
const fm = extractFrontmatter(content);
|
|
64
|
-
expect(fm.title).toBe("Hello");
|
|
65
|
-
expect(fm.description).toBe("World");
|
|
66
|
-
});
|
|
67
|
-
it("returns empty object for content without frontmatter", () => {
|
|
68
|
-
const fm = extractFrontmatter("# No frontmatter");
|
|
69
|
-
expect(fm).toEqual({});
|
|
70
|
-
});
|
|
71
|
-
it("throws on malformed YAML", () => {
|
|
72
|
-
const content = `---\ntitle: [\n---`;
|
|
73
|
-
expect(() => extractFrontmatter(content)).toThrow("Failed to extract frontmatter");
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
describe("extractFrontmatterWithContent", () => {
|
|
77
|
-
it("returns frontmatter and stripped content", () => {
|
|
78
|
-
const content = `---\ntitle: Test\n---\n## Hello`;
|
|
79
|
-
const result = extractFrontmatterWithContent(content);
|
|
80
|
-
expect(result.frontmatter.title).toBe("Test");
|
|
81
|
-
expect(result.strippedContent.trim()).toBe("## Hello");
|
|
82
|
-
});
|
|
83
|
-
it("strips frontmatter block from content", () => {
|
|
84
|
-
const content = `---\nkey: value\n---\nBody text`;
|
|
85
|
-
const result = extractFrontmatterWithContent(content);
|
|
86
|
-
expect(result.strippedContent).not.toContain("---");
|
|
87
|
-
expect(result.strippedContent.trim()).toBe("Body text");
|
|
88
|
-
});
|
|
89
|
-
it("handles content without frontmatter", () => {
|
|
90
|
-
const result = extractFrontmatterWithContent("# No frontmatter");
|
|
91
|
-
expect(result.frontmatter).toEqual({});
|
|
92
|
-
expect(result.strippedContent.trim()).toBe("# No frontmatter");
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
//# sourceMappingURL=extract.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract.test.js","sourceRoot":"","sources":["../../src/__tests__/extract.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,QAAQ,EACR,qBAAqB,EACrB,kBAAkB,EAClB,6BAA6B,GAC9B,MAAM,YAAY,CAAC;AAEpB,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iBAAiB,EAAE,GAAG,EAAE;QACzB,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,6BAA6B,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