@openuji/speculator 0.4.0 → 0.5.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 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/postprocess/__tests__/toc.test.d.ts +5 -0
- package/dist/postprocess/__tests__/toc.test.d.ts.map +1 -0
- package/dist/postprocess/__tests__/toc.test.js +257 -0
- package/dist/postprocess/__tests__/toc.test.js.map +1 -0
- package/dist/postprocess/index.d.ts +1 -0
- package/dist/postprocess/index.d.ts.map +1 -1
- package/dist/postprocess/index.js +5 -0
- package/dist/postprocess/index.js.map +1 -1
- package/dist/postprocess/plugins/toc.d.ts +19 -0
- package/dist/postprocess/plugins/toc.d.ts.map +1 -0
- package/dist/postprocess/plugins/toc.js +125 -0
- package/dist/postprocess/plugins/toc.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type { FileProvider } from './file-provider/types.js';
|
|
|
8
8
|
export * from './types/ast.generated.js';
|
|
9
9
|
export { speculate, SpeculatorPipeline, PHASES, POSTPROCESS_PHASES } from './pipeline/index.js';
|
|
10
10
|
export type { Plugin, Phase, PostprocessPhase, SpeculateOptions, SpeculateResult } from './pipeline/types.js';
|
|
11
|
-
export { citationTransformPlugin, dfnIndexPlugin, referenceResolvePlugin, corePlugins, } from './postprocess/index.js';
|
|
11
|
+
export { citationTransformPlugin, dfnIndexPlugin, referenceResolvePlugin, tocPlugin, corePlugins, } from './postprocess/index.js';
|
|
12
12
|
export { coreHtmlParsers, coreMarkdownParsers, } from './parse/parsers.js';
|
|
13
13
|
export { sortEntriesByDeps } from './workspace/index.js';
|
|
14
14
|
export type { EntryWithConfig, SortResult } from './workspace/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","s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AAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,cAAc,0BAA0B,CAAC;AAGzC,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAChG,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG9G,OAAO,EACH,uBAAuB,EACvB,cAAc,EACd,sBAAsB,EACtB,SAAS,EACT,WAAW,GACd,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACH,eAAe,EACf,mBAAmB,GACtB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export * from './types/ast.generated.js';
|
|
|
8
8
|
// Pipeline (Single Entrypoint)
|
|
9
9
|
export { speculate, SpeculatorPipeline, PHASES, POSTPROCESS_PHASES } from './pipeline/index.js';
|
|
10
10
|
// Postprocess Plugins
|
|
11
|
-
export { citationTransformPlugin, dfnIndexPlugin, referenceResolvePlugin, corePlugins, } from './postprocess/index.js';
|
|
11
|
+
export { citationTransformPlugin, dfnIndexPlugin, referenceResolvePlugin, tocPlugin, corePlugins, } from './postprocess/index.js';
|
|
12
12
|
// Parser Modules (for advanced use)
|
|
13
13
|
export { coreHtmlParsers, coreMarkdownParsers, } from './parse/parsers.js';
|
|
14
14
|
// Workspace Utilities
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,K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AAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toc.test.d.ts","sourceRoot":"","sources":["../../../src/postprocess/__tests__/toc.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TOC Plugin Tests
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect } from 'vitest';
|
|
5
|
+
import { tocPlugin } from '#src/postprocess/plugins/toc';
|
|
6
|
+
function createSectionWithHeading(headingText, depth, explicitId) {
|
|
7
|
+
const section = {
|
|
8
|
+
type: 'section',
|
|
9
|
+
heading: {
|
|
10
|
+
type: 'heading',
|
|
11
|
+
depth,
|
|
12
|
+
children: [{ type: 'text', value: headingText }],
|
|
13
|
+
},
|
|
14
|
+
children: [],
|
|
15
|
+
};
|
|
16
|
+
if (explicitId) {
|
|
17
|
+
section.id = explicitId;
|
|
18
|
+
}
|
|
19
|
+
return section;
|
|
20
|
+
}
|
|
21
|
+
function createDocWithSections(sections) {
|
|
22
|
+
return {
|
|
23
|
+
type: 'document',
|
|
24
|
+
children: sections,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
describe('TocPlugin', () => {
|
|
28
|
+
it('generates TOC from sections with headings', async () => {
|
|
29
|
+
const section1 = createSectionWithHeading('Introduction', 1, 'intro');
|
|
30
|
+
const section2 = createSectionWithHeading('Methods', 1, 'methods');
|
|
31
|
+
const doc = createDocWithSections([section1, section2]);
|
|
32
|
+
await tocPlugin.compute({ document: doc, level: 0 });
|
|
33
|
+
expect(doc.computed?.toc).toBeDefined();
|
|
34
|
+
expect(doc.computed.toc).toHaveLength(2);
|
|
35
|
+
expect(doc.computed.toc[0]).toMatchObject({
|
|
36
|
+
id: 'intro',
|
|
37
|
+
depth: 1,
|
|
38
|
+
text: 'Introduction',
|
|
39
|
+
number: '1',
|
|
40
|
+
});
|
|
41
|
+
expect(doc.computed.toc[1]).toMatchObject({
|
|
42
|
+
id: 'methods',
|
|
43
|
+
depth: 1,
|
|
44
|
+
text: 'Methods',
|
|
45
|
+
number: '2',
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
it('handles nested sections correctly', async () => {
|
|
49
|
+
const childSection = createSectionWithHeading('Sub Topic', 2, 'sub-topic');
|
|
50
|
+
const parentSection = createSectionWithHeading('Main Topic', 1, 'main-topic');
|
|
51
|
+
parentSection.children = [childSection];
|
|
52
|
+
const doc = createDocWithSections([parentSection]);
|
|
53
|
+
await tocPlugin.compute({ document: doc, level: 0 });
|
|
54
|
+
expect(doc.computed?.toc).toBeDefined();
|
|
55
|
+
expect(doc.computed.toc).toHaveLength(1);
|
|
56
|
+
expect(doc.computed.toc[0]).toMatchObject({
|
|
57
|
+
id: 'main-topic',
|
|
58
|
+
depth: 1,
|
|
59
|
+
text: 'Main Topic',
|
|
60
|
+
number: '1',
|
|
61
|
+
});
|
|
62
|
+
expect(doc.computed.toc[0].children).toHaveLength(1);
|
|
63
|
+
expect(doc.computed.toc[0].children[0]).toMatchObject({
|
|
64
|
+
id: 'sub-topic',
|
|
65
|
+
depth: 2,
|
|
66
|
+
text: 'Sub Topic',
|
|
67
|
+
number: '1.1',
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
it('generates correct heading numbers for multiple levels', async () => {
|
|
71
|
+
const child1 = createSectionWithHeading('First Child', 2, 'child-1');
|
|
72
|
+
const child2 = createSectionWithHeading('Second Child', 2, 'child-2');
|
|
73
|
+
const parent1 = createSectionWithHeading('First Parent', 1, 'parent-1');
|
|
74
|
+
parent1.children = [child1, child2];
|
|
75
|
+
const parent2 = createSectionWithHeading('Second Parent', 1, 'parent-2');
|
|
76
|
+
const child3 = createSectionWithHeading('Third Child', 2, 'child-3');
|
|
77
|
+
parent2.children = [child3];
|
|
78
|
+
const doc = createDocWithSections([parent1, parent2]);
|
|
79
|
+
await tocPlugin.compute({ document: doc, level: 0 });
|
|
80
|
+
expect(doc.computed?.headingNumbers).toEqual({
|
|
81
|
+
'parent-1': '1',
|
|
82
|
+
'child-1': '1.1',
|
|
83
|
+
'child-2': '1.2',
|
|
84
|
+
'parent-2': '2',
|
|
85
|
+
'child-3': '2.1',
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
it('empty document produces empty TOC', async () => {
|
|
89
|
+
const doc = {
|
|
90
|
+
type: 'document',
|
|
91
|
+
children: [],
|
|
92
|
+
};
|
|
93
|
+
await tocPlugin.compute({ document: doc, level: 0 });
|
|
94
|
+
expect(doc.computed?.toc).toEqual([]);
|
|
95
|
+
});
|
|
96
|
+
it('skips sections without headings', async () => {
|
|
97
|
+
const sectionWithHeading = createSectionWithHeading('Has Heading', 1, 'has-heading');
|
|
98
|
+
const sectionWithoutHeading = {
|
|
99
|
+
type: 'section',
|
|
100
|
+
children: [],
|
|
101
|
+
};
|
|
102
|
+
const doc = createDocWithSections([sectionWithHeading, sectionWithoutHeading]);
|
|
103
|
+
await tocPlugin.compute({ document: doc, level: 0 });
|
|
104
|
+
expect(doc.computed?.toc).toHaveLength(1);
|
|
105
|
+
expect(doc.computed.toc[0].text).toBe('Has Heading');
|
|
106
|
+
});
|
|
107
|
+
it('handles heading with inline code', async () => {
|
|
108
|
+
const section = {
|
|
109
|
+
type: 'section',
|
|
110
|
+
id: 'getelementbyid',
|
|
111
|
+
heading: {
|
|
112
|
+
type: 'heading',
|
|
113
|
+
depth: 1,
|
|
114
|
+
children: [
|
|
115
|
+
{ type: 'text', value: 'Using ' },
|
|
116
|
+
{ type: 'inlineCode', value: 'getElementById' },
|
|
117
|
+
{ type: 'text', value: ' method' },
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
children: [],
|
|
121
|
+
};
|
|
122
|
+
const doc = createDocWithSections([section]);
|
|
123
|
+
await tocPlugin.compute({ document: doc, level: 0 });
|
|
124
|
+
expect(doc.computed.toc[0].text).toBe('Using getElementById method');
|
|
125
|
+
});
|
|
126
|
+
it('handles heading with emphasis and strong', async () => {
|
|
127
|
+
const section = {
|
|
128
|
+
type: 'section',
|
|
129
|
+
id: 'important-notes',
|
|
130
|
+
heading: {
|
|
131
|
+
type: 'heading',
|
|
132
|
+
depth: 1,
|
|
133
|
+
children: [
|
|
134
|
+
{ type: 'emphasis', children: [{ type: 'text', value: 'Important' }] },
|
|
135
|
+
{ type: 'text', value: ' ' },
|
|
136
|
+
{ type: 'strong', children: [{ type: 'text', value: 'Notes' }] },
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
children: [],
|
|
140
|
+
};
|
|
141
|
+
const doc = createDocWithSections([section]);
|
|
142
|
+
await tocPlugin.compute({ document: doc, level: 0 });
|
|
143
|
+
expect(doc.computed.toc[0].text).toBe('Important Notes');
|
|
144
|
+
});
|
|
145
|
+
it('handles heading with link', async () => {
|
|
146
|
+
const section = {
|
|
147
|
+
type: 'section',
|
|
148
|
+
id: 'see-docs',
|
|
149
|
+
heading: {
|
|
150
|
+
type: 'heading',
|
|
151
|
+
depth: 1,
|
|
152
|
+
children: [
|
|
153
|
+
{ type: 'text', value: 'See ' },
|
|
154
|
+
{
|
|
155
|
+
type: 'link',
|
|
156
|
+
url: 'https://example.com',
|
|
157
|
+
children: [{ type: 'text', value: 'Documentation' }]
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
children: [],
|
|
162
|
+
};
|
|
163
|
+
const doc = createDocWithSections([section]);
|
|
164
|
+
await tocPlugin.compute({ document: doc, level: 0 });
|
|
165
|
+
expect(doc.computed.toc[0].text).toBe('See Documentation');
|
|
166
|
+
});
|
|
167
|
+
it('handles deeply nested sections (3+ levels)', async () => {
|
|
168
|
+
const level3 = createSectionWithHeading('Level 3', 3, 'level-3');
|
|
169
|
+
const level2 = createSectionWithHeading('Level 2', 2, 'level-2');
|
|
170
|
+
level2.children = [level3];
|
|
171
|
+
const level1 = createSectionWithHeading('Level 1', 1, 'level-1');
|
|
172
|
+
level1.children = [level2];
|
|
173
|
+
const doc = createDocWithSections([level1]);
|
|
174
|
+
await tocPlugin.compute({ document: doc, level: 0 });
|
|
175
|
+
expect(doc.computed?.headingNumbers).toEqual({
|
|
176
|
+
'level-1': '1',
|
|
177
|
+
'level-2': '1.1',
|
|
178
|
+
'level-3': '1.1.1',
|
|
179
|
+
});
|
|
180
|
+
const tocLevel1 = doc.computed.toc[0];
|
|
181
|
+
const tocLevel2 = tocLevel1.children[0];
|
|
182
|
+
const tocLevel3 = tocLevel2.children[0];
|
|
183
|
+
expect(tocLevel3.number).toBe('1.1.1');
|
|
184
|
+
});
|
|
185
|
+
it('handles sections without IDs (no heading number stored)', async () => {
|
|
186
|
+
const section = createSectionWithHeading('No ID Section', 1);
|
|
187
|
+
// No ID assigned
|
|
188
|
+
const doc = createDocWithSections([section]);
|
|
189
|
+
await tocPlugin.compute({ document: doc, level: 0 });
|
|
190
|
+
expect(doc.computed?.toc).toHaveLength(1);
|
|
191
|
+
expect(doc.computed.toc[0]).toMatchObject({
|
|
192
|
+
depth: 1,
|
|
193
|
+
text: 'No ID Section',
|
|
194
|
+
number: '1',
|
|
195
|
+
});
|
|
196
|
+
expect(doc.computed.toc[0].id).toBeUndefined();
|
|
197
|
+
// headingNumbers should be empty or not contain this section
|
|
198
|
+
expect(doc.computed?.headingNumbers).toBeUndefined();
|
|
199
|
+
});
|
|
200
|
+
it('preserves existing computed fields', async () => {
|
|
201
|
+
const section = createSectionWithHeading('Test', 1, 'test');
|
|
202
|
+
const doc = createDocWithSections([section]);
|
|
203
|
+
doc.computed = {
|
|
204
|
+
wordCount: 100,
|
|
205
|
+
readingTime: 5,
|
|
206
|
+
};
|
|
207
|
+
await tocPlugin.compute({ document: doc, level: 0 });
|
|
208
|
+
expect(doc.computed.wordCount).toBe(100);
|
|
209
|
+
expect(doc.computed.readingTime).toBe(5);
|
|
210
|
+
expect(doc.computed.toc).toBeDefined();
|
|
211
|
+
});
|
|
212
|
+
it('handles heading with definition', async () => {
|
|
213
|
+
const section = {
|
|
214
|
+
type: 'section',
|
|
215
|
+
id: 'about-loop',
|
|
216
|
+
heading: {
|
|
217
|
+
type: 'heading',
|
|
218
|
+
depth: 1,
|
|
219
|
+
children: [
|
|
220
|
+
{ type: 'text', value: 'About ' },
|
|
221
|
+
{
|
|
222
|
+
type: 'definition',
|
|
223
|
+
term: 'event loop',
|
|
224
|
+
children: [{ type: 'text', value: 'Event Loop' }]
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
},
|
|
228
|
+
children: [],
|
|
229
|
+
};
|
|
230
|
+
const doc = createDocWithSections([section]);
|
|
231
|
+
await tocPlugin.compute({ document: doc, level: 0 });
|
|
232
|
+
expect(doc.computed.toc[0].text).toBe('About event loop');
|
|
233
|
+
});
|
|
234
|
+
it('handles heading with reference', async () => {
|
|
235
|
+
const section = {
|
|
236
|
+
type: 'section',
|
|
237
|
+
id: 'understanding',
|
|
238
|
+
heading: {
|
|
239
|
+
type: 'heading',
|
|
240
|
+
depth: 1,
|
|
241
|
+
children: [
|
|
242
|
+
{ type: 'text', value: 'Understanding ' },
|
|
243
|
+
{
|
|
244
|
+
type: 'reference',
|
|
245
|
+
targetTerm: 'task queue',
|
|
246
|
+
children: [{ type: 'text', value: 'Task Queue' }]
|
|
247
|
+
},
|
|
248
|
+
],
|
|
249
|
+
},
|
|
250
|
+
children: [],
|
|
251
|
+
};
|
|
252
|
+
const doc = createDocWithSections([section]);
|
|
253
|
+
await tocPlugin.compute({ document: doc, level: 0 });
|
|
254
|
+
expect(doc.computed.toc[0].text).toBe('Understanding task queue');
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
//# sourceMappingURL=toc.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toc.test.js","sourceRoot":"","sources":["../../../src/postprocess/__tests__/toc.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,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AAC,CAAC,CAAC;QAE7C,MAAM,SAAS,CAAC,OAAQ,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QAEtD,MAAM,CAAC,GAAG,CAAC,QAAS,CAAC,GAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -10,6 +10,7 @@ export { citationTransformPlugin } from './plugins/citation-transform.js';
|
|
|
10
10
|
export { sectionIdPlugin } from './plugins/section-id.js';
|
|
11
11
|
export { dfnIndexPlugin } from './plugins/dfn-index.js';
|
|
12
12
|
export { referenceResolvePlugin } from './plugins/reference-resolve.js';
|
|
13
|
+
export { tocPlugin } from './plugins/toc.js';
|
|
13
14
|
export { walkDocument, type AstVisitor } from './walk-ast.js';
|
|
14
15
|
export declare const corePlugins: import("../index.js").Plugin[];
|
|
15
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/postprocess/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAG1E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAGxE,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/postprocess/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAG1E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAGxE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAa9D,eAAO,MAAM,WAAW,gCAUvB,CAAC"}
|
|
@@ -13,6 +13,8 @@ export { sectionIdPlugin } from './plugins/section-id.js';
|
|
|
13
13
|
export { dfnIndexPlugin } from './plugins/dfn-index.js';
|
|
14
14
|
// Resolve plugins
|
|
15
15
|
export { referenceResolvePlugin } from './plugins/reference-resolve.js';
|
|
16
|
+
// Compute plugins
|
|
17
|
+
export { tocPlugin } from './plugins/toc.js';
|
|
16
18
|
// Utilities
|
|
17
19
|
export { walkDocument } from './walk-ast.js';
|
|
18
20
|
/**
|
|
@@ -24,6 +26,7 @@ import { citationTransformPlugin } from './plugins/citation-transform.js';
|
|
|
24
26
|
import { sectionIdPlugin } from './plugins/section-id.js';
|
|
25
27
|
import { dfnIndexPlugin } from './plugins/dfn-index.js';
|
|
26
28
|
import { referenceResolvePlugin } from './plugins/reference-resolve.js';
|
|
29
|
+
import { tocPlugin } from './plugins/toc.js';
|
|
27
30
|
export const corePlugins = [
|
|
28
31
|
// Transform plugins
|
|
29
32
|
citationTransformPlugin, // order: { transform: 10 }
|
|
@@ -32,5 +35,7 @@ export const corePlugins = [
|
|
|
32
35
|
dfnIndexPlugin, // order: { index: 10 }
|
|
33
36
|
// Resolve plugins
|
|
34
37
|
referenceResolvePlugin, // order: { resolve: 10 }
|
|
38
|
+
// Compute plugins
|
|
39
|
+
tocPlugin, // order: { compute: 10 }
|
|
35
40
|
];
|
|
36
41
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/postprocess/index.ts"],"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AAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,oBAAoB;IACpB,uBAAuB,EAAK,2BAA2B;IACvD,gBAAgB;IAChB,eAAe,EAAa,sBAAsB;IAClD,cAAc,EAAc,uBAAuB;IACnD,kBAAkB;IAClB,sBAAsB,EAAM,yBAAyB;IACrD,kBAAkB;IAClB,SAAS,EAAmB,yBAAyB;CACxD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TOC (Table of Contents) Plugin
|
|
3
|
+
*
|
|
4
|
+
* Generates a hierarchical table of contents from document sections.
|
|
5
|
+
* Runs during the compute phase to populate document.computed.toc
|
|
6
|
+
* and document.computed.headingNumbers.
|
|
7
|
+
*
|
|
8
|
+
* Process:
|
|
9
|
+
* 1. Walk AST to find all Section nodes with headings
|
|
10
|
+
* 2. Build hierarchical TOC entries with depth and text
|
|
11
|
+
* 3. Generate hierarchical heading numbers (1, 1.1, 1.2, 2, etc.)
|
|
12
|
+
* 4. Populate computed fields on the document
|
|
13
|
+
*/
|
|
14
|
+
import type { Plugin } from '#src/pipeline/types';
|
|
15
|
+
/**
|
|
16
|
+
* TOC plugin
|
|
17
|
+
*/
|
|
18
|
+
export declare const tocPlugin: Plugin;
|
|
19
|
+
//# sourceMappingURL=toc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toc.d.ts","sourceRoot":"","sources":["../../../src/postprocess/plugins/toc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,qBAAqB,CAAC;AAoIlE;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MAOvB,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TOC (Table of Contents) Plugin
|
|
3
|
+
*
|
|
4
|
+
* Generates a hierarchical table of contents from document sections.
|
|
5
|
+
* Runs during the compute phase to populate document.computed.toc
|
|
6
|
+
* and document.computed.headingNumbers.
|
|
7
|
+
*
|
|
8
|
+
* Process:
|
|
9
|
+
* 1. Walk AST to find all Section nodes with headings
|
|
10
|
+
* 2. Build hierarchical TOC entries with depth and text
|
|
11
|
+
* 3. Generate hierarchical heading numbers (1, 1.1, 1.2, 2, etc.)
|
|
12
|
+
* 4. Populate computed fields on the document
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Extract plain text from heading inline nodes
|
|
16
|
+
* Reused pattern from section-id.ts
|
|
17
|
+
*/
|
|
18
|
+
function extractHeadingText(heading) {
|
|
19
|
+
function extractFromInlines(inlines) {
|
|
20
|
+
return inlines
|
|
21
|
+
.map(inline => {
|
|
22
|
+
switch (inline.type) {
|
|
23
|
+
case 'text':
|
|
24
|
+
return inline.value;
|
|
25
|
+
case 'emphasis':
|
|
26
|
+
case 'strong':
|
|
27
|
+
case 'link':
|
|
28
|
+
return extractFromInlines(inline.children);
|
|
29
|
+
case 'inlineCode':
|
|
30
|
+
return inline.value;
|
|
31
|
+
case 'definition':
|
|
32
|
+
return inline.term;
|
|
33
|
+
case 'reference':
|
|
34
|
+
return inline.targetTerm;
|
|
35
|
+
case 'issue':
|
|
36
|
+
return extractFromInlines(inline.children);
|
|
37
|
+
case 'cite':
|
|
38
|
+
return inline.children ? extractFromInlines(inline.children) : inline.key;
|
|
39
|
+
default:
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
.join('');
|
|
44
|
+
}
|
|
45
|
+
return extractFromInlines(heading.children);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Build TOC entries recursively from sections
|
|
49
|
+
*/
|
|
50
|
+
function buildTocFromSections(children, counters, headingNumbers) {
|
|
51
|
+
const entries = [];
|
|
52
|
+
for (const child of children) {
|
|
53
|
+
if (child.type !== 'section')
|
|
54
|
+
continue;
|
|
55
|
+
const section = child;
|
|
56
|
+
// Skip sections without headings
|
|
57
|
+
if (!section.heading)
|
|
58
|
+
continue;
|
|
59
|
+
const depth = section.heading.depth;
|
|
60
|
+
const text = extractHeadingText(section.heading);
|
|
61
|
+
// Adjust counters array to match current depth
|
|
62
|
+
// depth 1 = index 0, depth 2 = index 1, etc.
|
|
63
|
+
const depthIndex = depth - 1;
|
|
64
|
+
// Ensure counters array is long enough
|
|
65
|
+
while (counters.length <= depthIndex) {
|
|
66
|
+
counters.push(0);
|
|
67
|
+
}
|
|
68
|
+
// Increment counter at current depth
|
|
69
|
+
counters[depthIndex]++;
|
|
70
|
+
// Reset all deeper counters
|
|
71
|
+
for (let i = depthIndex + 1; i < counters.length; i++) {
|
|
72
|
+
counters[i] = 0;
|
|
73
|
+
}
|
|
74
|
+
// Build number string from counters (only up to current depth)
|
|
75
|
+
const numberParts = counters.slice(0, depthIndex + 1).filter(n => n > 0);
|
|
76
|
+
const number = numberParts.join('.');
|
|
77
|
+
// Store heading number if section has an ID
|
|
78
|
+
if (section.id && number) {
|
|
79
|
+
headingNumbers.set(section.id, number);
|
|
80
|
+
}
|
|
81
|
+
// Recursively process nested sections
|
|
82
|
+
const nestedChildren = buildTocFromSections(section.children, [...counters], // Pass a copy to avoid mutation issues
|
|
83
|
+
headingNumbers);
|
|
84
|
+
const entry = {
|
|
85
|
+
id: section.id,
|
|
86
|
+
depth,
|
|
87
|
+
text,
|
|
88
|
+
number,
|
|
89
|
+
};
|
|
90
|
+
if (nestedChildren.length > 0) {
|
|
91
|
+
entry.children = nestedChildren;
|
|
92
|
+
}
|
|
93
|
+
entries.push(entry);
|
|
94
|
+
}
|
|
95
|
+
return entries;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Generate TOC and heading numbers for a document
|
|
99
|
+
*/
|
|
100
|
+
function generateToc(document) {
|
|
101
|
+
const headingNumbers = new Map();
|
|
102
|
+
const counters = [];
|
|
103
|
+
const toc = buildTocFromSections(document.children, counters, headingNumbers);
|
|
104
|
+
// Initialize computed fields if not present
|
|
105
|
+
if (!document.computed) {
|
|
106
|
+
document.computed = {};
|
|
107
|
+
}
|
|
108
|
+
// Set TOC
|
|
109
|
+
document.computed.toc = toc;
|
|
110
|
+
// Convert Map to plain object for headingNumbers
|
|
111
|
+
if (headingNumbers.size > 0) {
|
|
112
|
+
document.computed.headingNumbers = Object.fromEntries(headingNumbers);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* TOC plugin
|
|
117
|
+
*/
|
|
118
|
+
export const tocPlugin = {
|
|
119
|
+
name: 'toc',
|
|
120
|
+
order: { compute: 10 },
|
|
121
|
+
async compute(ctx) {
|
|
122
|
+
generateToc(ctx.document);
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=toc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toc.js","sourceRoot":"","sources":["../../../src/postprocess/plugins/toc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH;;;GAGG;AACH,SAAS,kBAAkB,CAAC,OAAqB;IAC7C,SAAS,kBAAkB,CAAC,OAAiB;QACzC,OAAO,OAAO;aACT,GAAG,CAAC,MAAM,CAAC,EAAE;YACV,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;gBAClB,KAAK,MAAM;oBACP,OAAO,MAAM,CAAC,KAAK,CAAC;gBACxB,KAAK,UAAU,CAAC;gBAChB,KAAK,QAAQ,CAAC;gBACd,KAAK,MAAM;oBACP,OAAO,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAC/C,KAAK,YAAY;oBACb,OAAO,MAAM,CAAC,KAAK,CAAC;gBACxB,KAAK,YAAY;oBACb,OAAO,MAAM,CAAC,IAAI,CAAC;gBACvB,KAAK,WAAW;oBACZ,OAAO,MAAM,CAAC,UAAU,CAAC;gBAC7B,KAAK,OAAO;oBAC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