remark-flexible-toc 1.2.7 → 1.2.8
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 +36 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -41
- package/dist/index.js.map +1 -1
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@ A warm thanks 🙌 to [@ErfanEbrahimnia](https://github.com/ErfanEbrahimnia), [@
|
|
|
20
20
|
|
|
21
21
|
This package is a [**unified**][unified] ([**remark**][remark]) plugin **to expose the table of contents via `Vfile.data` or via an option reference in markdown.**
|
|
22
22
|
|
|
23
|
+
**`remark-flexible-toc`** also exports `generateTocItemsFromMdast` to generate the table of contents items directly from an MDAST tree without requiring a unified processor or a VFile.
|
|
24
|
+
|
|
23
25
|
[**unified**][unified] is a project that transforms content with abstract syntax trees (ASTs) using the new parser [**micromark**][micromark]. [**remark**][remark] adds support for markdown to unified. [**mdast**][mdast] is the Markdown Abstract Syntax Tree (AST) which is a specification for representing markdown in a syntax tree.
|
|
24
26
|
|
|
25
27
|
**This plugin is a remark plugin that doesn't transform the MDAST but gets info from the MDAST.**
|
|
@@ -29,6 +31,7 @@ This package is a [**unified**][unified] ([**remark**][remark]) plugin **to expo
|
|
|
29
31
|
**`remark-flexible-toc`** is useful if you want to get the table of contents (TOC) from the markdown/MDX document. It exposes the table of contents (TOC) in two ways:
|
|
30
32
|
+ by adding a `toc` object into `Vfile.data`
|
|
31
33
|
+ by mutating a reference array if provided in the options
|
|
34
|
+
+ by generating `TocItem[]` directly from an MDAST tree with `generateTocItemsFromMdast`
|
|
32
35
|
|
|
33
36
|
## Installation
|
|
34
37
|
|
|
@@ -140,6 +143,24 @@ Now, running both `node example.js` you will see that the same table of contents
|
|
|
140
143
|
|
|
141
144
|
Without **`remark-flexible-toc`**, there wouldn't be any `toc` key in the `file.data`:
|
|
142
145
|
|
|
146
|
+
#### Generating TOC items directly from MDAST
|
|
147
|
+
|
|
148
|
+
If you already have an MDAST tree, you can generate the table of contents items directly without using the remark plugin, a unified processor, or a VFile.
|
|
149
|
+
|
|
150
|
+
```js
|
|
151
|
+
import { generateTocItemsFromMdast } from "remark-flexible-toc";
|
|
152
|
+
|
|
153
|
+
const tocItems = generateTocItemsFromMdast(tree, {
|
|
154
|
+
maxDepth: 4,
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
console.log(tocItems);
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The function returns `TocItem[]` and does not modify the MDAST tree.
|
|
161
|
+
|
|
162
|
+
The available options are `maxDepth`, `skipLevels`, `skipParents`, `exclude`, and `prefix`.
|
|
163
|
+
|
|
143
164
|
## Options
|
|
144
165
|
|
|
145
166
|
All options are **optional**.
|
|
@@ -167,6 +188,16 @@ use(remarkFlexibleToc, {
|
|
|
167
188
|
} as FlexibleTocOptions);
|
|
168
189
|
```
|
|
169
190
|
|
|
191
|
+
`generateTocItemsFromMdast` accepts only the options related to generating the TOC items. The plugin-specific `tocName`, `tocRef`, and `callback` options are not applicable.
|
|
192
|
+
|
|
193
|
+
```ts
|
|
194
|
+
type GenerateTocItemsOptions = Pick<
|
|
195
|
+
FlexibleTocOptions,
|
|
196
|
+
"maxDepth" | "skipLevels" | "skipParents" | "exclude" | "prefix"
|
|
197
|
+
>;
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
|
|
170
201
|
#### `tocName`
|
|
171
202
|
|
|
172
203
|
It is a **string** option in which the table of contents (TOC) is placed in the `vfile.data`.
|
|
@@ -382,9 +413,13 @@ tocItem.numbering.join("-");
|
|
|
382
413
|
|
|
383
414
|
This plugin does not modify the `mdast` (markdown abstract syntax tree), collects data from the `mdast` and adds information into the `vfile.data` if required.
|
|
384
415
|
|
|
416
|
+
`generateTocItemsFromMdast` also does not modify the provided MDAST tree.
|
|
417
|
+
|
|
385
418
|
## Types
|
|
386
419
|
|
|
387
|
-
This package is fully typed with [TypeScript][url-typescript]
|
|
420
|
+
This package is fully typed with [TypeScript][url-typescript] and also exports the `generateTocItemsFromMdast` utility function.
|
|
421
|
+
|
|
422
|
+
The plugin exports the types `FlexibleTocOptions`, `HeadingParent`, `HeadingDepth`, `TocItem` and `GenerateTocItemsOptions`.
|
|
388
423
|
|
|
389
424
|
## Compatibility
|
|
390
425
|
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export type FlexibleTocOptions = {
|
|
|
36
36
|
prefix?: string;
|
|
37
37
|
callback?: (toc: TocItem[]) => undefined;
|
|
38
38
|
};
|
|
39
|
+
export type GenerateTocItemsOptions = Pick<FlexibleTocOptions, "maxDepth" | "skipLevels" | "skipParents" | "exclude" | "prefix">;
|
|
40
|
+
export declare function generateTocItemsFromMdast(tree: Root, options?: GenerateTocItemsOptions): TocItem[];
|
|
39
41
|
declare const RemarkFlexibleToc: Plugin<[FlexibleTocOptions?], Root>;
|
|
40
42
|
export default RemarkFlexibleToc;
|
|
41
43
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAKlC,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,EAAE,CAAC;AAExD,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAExF,MAAM,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.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AAY,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,EAAE,CAAC;IAC/C,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,SAAS,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,kBAAkB,EAClB,UAAU,GAAG,YAAY,GAAG,aAAa,GAAG,SAAS,GAAG,QAAQ,CACjE,CAAC;AA4DF,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,EAAE,CA8DX;AAED,QAAA,MAAM,iBAAiB,EAAE,MAAM,CAAC,CAAC,kBAAkB,CAAC,CAAC,EAAE,IAAI,CA+B1D,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -47,54 +47,59 @@ function addNumbering(arr) {
|
|
|
47
47
|
tocItem.numbering = numbering;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
export function generateTocItemsFromMdast(tree, options) {
|
|
51
51
|
const settings = Object.assign({}, DEFAULT_SETTINGS, options);
|
|
52
52
|
const exludeRegexFilter = settings.exclude &&
|
|
53
53
|
(Array.isArray(settings.exclude)
|
|
54
54
|
? new RegExp("^(" + settings.exclude.join("|") + ")$", "i")
|
|
55
55
|
: new RegExp("^(" + settings.exclude + ")$", "i"));
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (parent !== "root" && settings.skipParents.includes(parent))
|
|
75
|
-
return CONTINUE;
|
|
76
|
-
// exclude check
|
|
77
|
-
if (exludeRegexFilter && exludeRegexFilter.test(value))
|
|
78
|
-
return CONTINUE;
|
|
79
|
-
// Other remark plugins can store custom data in node.data.hProperties
|
|
80
|
-
// I omitted node.data.hName and node.data.hChildren since not related with toc
|
|
81
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
82
|
-
// @ts-ignore, vscode resolves the type but tsc build raises an error awkwardly, saying "hProperties" does not exist in "HeadingData".
|
|
83
|
-
const hProperties = _node.data?.hProperties;
|
|
84
|
-
const data = hProperties ? { ...hProperties } : undefined;
|
|
85
|
-
if (data?.["id"])
|
|
86
|
-
href = `#${data["id"]}`;
|
|
87
|
-
tocItems.push({
|
|
88
|
-
value,
|
|
89
|
-
href,
|
|
90
|
-
depth,
|
|
91
|
-
numbering: [],
|
|
92
|
-
parent,
|
|
93
|
-
...(data && { data }),
|
|
94
|
-
});
|
|
56
|
+
const slugger = new GithubSlugger();
|
|
57
|
+
const tocItems = [];
|
|
58
|
+
visit(tree, "heading", (_node, _index, _parent) => {
|
|
59
|
+
/* v8 ignore next -- @preserve */
|
|
60
|
+
if (!_parent || typeof _index === "undefined")
|
|
61
|
+
return;
|
|
62
|
+
const depth = _node.depth;
|
|
63
|
+
const value = toString(_node, { includeImageAlt: false });
|
|
64
|
+
let href = `#${settings.prefix ?? ""}${slugger.slug(value)}`;
|
|
65
|
+
const parent = _parent.type;
|
|
66
|
+
// maxDepth check
|
|
67
|
+
if (depth > settings.maxDepth)
|
|
68
|
+
return CONTINUE;
|
|
69
|
+
// skipLevels check
|
|
70
|
+
if (settings.skipLevels.includes(depth))
|
|
71
|
+
return CONTINUE;
|
|
72
|
+
// skipParents check
|
|
73
|
+
if (parent !== "root" && settings.skipParents.includes(parent))
|
|
95
74
|
return CONTINUE;
|
|
75
|
+
// exclude check
|
|
76
|
+
if (exludeRegexFilter && exludeRegexFilter.test(value))
|
|
77
|
+
return CONTINUE;
|
|
78
|
+
// Other remark plugins can store custom data in node.data.hProperties
|
|
79
|
+
// I omitted node.data.hName and node.data.hChildren since not related with toc
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
81
|
+
// @ts-ignore, vscode resolves the type but tsc build raises an error awkwardly, saying "hProperties" does not exist in "HeadingData".
|
|
82
|
+
const hProperties = _node.data?.hProperties;
|
|
83
|
+
const data = hProperties ? { ...hProperties } : undefined;
|
|
84
|
+
if (data?.["id"])
|
|
85
|
+
href = `#${data["id"]}`;
|
|
86
|
+
tocItems.push({
|
|
87
|
+
value,
|
|
88
|
+
href,
|
|
89
|
+
depth,
|
|
90
|
+
numbering: [],
|
|
91
|
+
parent,
|
|
92
|
+
...(data && { data }),
|
|
96
93
|
});
|
|
97
|
-
|
|
94
|
+
return CONTINUE;
|
|
95
|
+
});
|
|
96
|
+
addNumbering(tocItems);
|
|
97
|
+
return tocItems;
|
|
98
|
+
}
|
|
99
|
+
const RemarkFlexibleToc = (options) => {
|
|
100
|
+
const settings = Object.assign({}, DEFAULT_SETTINGS, options);
|
|
101
|
+
return (tree, file) => {
|
|
102
|
+
const tocItems = generateTocItemsFromMdast(tree, options);
|
|
98
103
|
// it is allowed to modify the TOC in the callback
|
|
99
104
|
settings.callback?.(tocItems);
|
|
100
105
|
// method - 1 for exposing the data via vfile.data **************************
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAuDhD,MAAM,gBAAgB,GAAuB;IAC3C,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,CAAC;IACX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0DAA0D;QAC1D,2DAA2D;QAC3D,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;QAE5C,6EAA6E;QAE7E,IAAI,OAAO,EAAE,MAAM,EAAE,CAAC;YACpB,6DAA6D;YAC7D,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;YAE3B,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC3B,yDAAyD;gBACzD,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC","sourcesContent":["import type { Plugin } from \"unified\";\nimport type { Root } from \"mdast\";\nimport { visit, CONTINUE } from \"unist-util-visit\";\nimport GithubSlugger from \"github-slugger\";\nimport { toString } from \"mdast-util-to-string\";\n\nexport type Prettify<T> = { [K in keyof T]: T[K] } & {};\n\nexport type PartiallyRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;\n\nexport type HeadingParent =\n | \"root\"\n | \"blockquote\"\n | \"footnoteDefinition\"\n | \"listItem\"\n | \"container\"\n | \"mdxJsxFlowElement\";\n\nexport type HeadingDepth = 1 | 2 | 3 | 4 | 5 | 6;\n\nexport type TocItem = {\n value: string;\n href: string;\n depth: HeadingDepth;\n numbering: number[];\n parent: HeadingParent;\n data?: {\n [PropertyName: string]: string | number | boolean | (string | number)[] | null | undefined;\n };\n};\n\n/**\n * tocName (default: \"toc\") - the key name which is attached into vfile.data\n * tocRef (default: []) — another way of exposing the tocItems\n * maxDepth (default: 6) — max heading depth to include in the table of contents; this is inclusive: when set to 3, level three headings are included\n * skipLevels (default: [1]) — disallowed heading levels, by default the article h1 is not expected to be in the TOC\n * skipParents (default: []) — disallow headings to be children of certain node types, (the \"root\" can not be skipped)\n * exclude — headings to skip, wrapped in new RegExp('^(' + value + ')$', 'i'); any heading matching this expression will not be present in the table of contents\n * prefix - the text that will be attached to headings as prefix, like \"text-prefix-\"\n * callback - It is a callback function to take the array of toc items as an argument\n */\nexport type FlexibleTocOptions = {\n tocName?: string;\n tocRef?: TocItem[];\n maxDepth?: HeadingDepth;\n skipLevels?: HeadingDepth[];\n skipParents?: Exclude<HeadingParent, \"root\">[];\n exclude?: string | string[];\n prefix?: string;\n callback?: (toc: TocItem[]) => undefined;\n};\n\ntype PartiallyRequiredFlexibleTocOptions = Prettify<\n PartiallyRequired<\n FlexibleTocOptions,\n \"tocName\" | \"tocRef\" | \"maxDepth\" | \"skipLevels\" | \"skipParents\"\n >\n>;\n\nconst DEFAULT_SETTINGS: FlexibleTocOptions = {\n tocName: \"toc\",\n tocRef: [],\n maxDepth: 6,\n skipLevels: [1],\n skipParents: [],\n};\n\n/**\n * adds numberings to the TOC items.\n * why \"number[]\"? It is because up to you joining with dot or dash or slicing the first number (reserved for h1)\n *\n * [1]\n * [1,1]\n * [1,2]\n * [1,2,1]\n */\nfunction addNumbering(arr: TocItem[]) {\n for (let i = 0; i < arr.length; i++) {\n const tocItem = arr[i];\n const depth = tocItem.depth;\n\n let numbering: number[];\n\n const prevObj = i > 0 ? arr[i - 1] : undefined;\n const prevDepth = prevObj ? prevObj.depth : undefined;\n const prevNumbering = prevObj ? prevObj.numbering : undefined;\n\n if (!prevNumbering || !prevDepth) {\n numbering = Array.from({ length: depth }, () => 1);\n } else if (depth === prevDepth) {\n numbering = [...prevNumbering];\n numbering[depth - 1]++;\n } else if (depth > prevDepth) {\n numbering = [\n ...prevNumbering,\n ...(Array.from(\n { length: depth - prevDepth }, // if depth is more bigger than prevDepth, put more \"1\" inside the array\n () => 1,\n ) as HeadingDepth[]),\n ];\n } else {\n // if (depth < prevDepth)\n numbering = prevNumbering.slice(0, depth);\n numbering[depth - 1]++;\n }\n\n tocItem.numbering = numbering;\n }\n}\n\nconst RemarkFlexibleToc: Plugin<[FlexibleTocOptions?], Root> = (options) => {\n const settings = Object.assign(\n {},\n DEFAULT_SETTINGS,\n options,\n ) as PartiallyRequiredFlexibleTocOptions;\n\n const exludeRegexFilter =\n settings.exclude &&\n (Array.isArray(settings.exclude)\n ? new RegExp(\"^(\" + settings.exclude.join(\"|\") + \")$\", \"i\")\n : new RegExp(\"^(\" + settings.exclude + \")$\", \"i\"));\n\n return (tree, file) => {\n const slugger = new GithubSlugger();\n const tocItems: TocItem[] = [];\n\n visit(tree, \"heading\", (_node, _index, _parent) => {\n /* v8 ignore next -- @preserve */\n if (!_parent || typeof _index === \"undefined\") return;\n\n const depth = _node.depth;\n const value = toString(_node, { includeImageAlt: false });\n let href = `#${settings.prefix ?? \"\"}${slugger.slug(value)}`;\n const parent = _parent.type;\n\n // maxDepth check\n if (depth > settings.maxDepth) return CONTINUE;\n\n // skipLevels check\n if (settings.skipLevels.includes(depth)) return CONTINUE;\n\n // skipParents check\n if (parent !== \"root\" && settings.skipParents.includes(parent)) return CONTINUE;\n\n // exclude check\n if (exludeRegexFilter && exludeRegexFilter.test(value)) return CONTINUE;\n\n // Other remark plugins can store custom data in node.data.hProperties\n // I omitted node.data.hName and node.data.hChildren since not related with toc\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore, vscode resolves the type but tsc build raises an error awkwardly, saying \"hProperties\" does not exist in \"HeadingData\".\n const hProperties = _node.data?.hProperties;\n const data = hProperties ? { ...hProperties } : undefined;\n\n if (data?.[\"id\"]) href = `#${data[\"id\"]}`;\n\n tocItems.push({\n value,\n href,\n depth,\n numbering: [],\n parent,\n ...(data && { data }),\n });\n\n return CONTINUE;\n });\n\n addNumbering(tocItems);\n\n // it is allowed to modify the TOC in the callback\n settings.callback?.(tocItems);\n\n // method - 1 for exposing the data via vfile.data **************************\n\n // other plugins are not allowed to mutate the exposed TOC\n // The spreading is slower than push but need to fresh copy\n file.data[settings.tocName] = [...tocItems];\n\n // method - 2 for exposing the data via reference array *********************\n\n if (options?.tocRef) {\n // prevent dublication if the plugin is called more than once\n settings.tocRef.length = 0;\n\n tocItems.forEach((tocItem) => {\n // the tocRef is not allowed to mutate the vfile.data.toc\n settings.tocRef.push(tocItem);\n });\n }\n };\n};\n\nexport default RemarkFlexibleToc;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAuDhD,MAAM,gBAAgB,GAAuB;IAC3C,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,CAAC;IACX,UAAU,EAAE,CAAC,CAAC,CAAC;IACf,WAAW,EAAE,EAAE;CAChB,CAAC;AAEF;;;;;;;;GAQG;AACH,SAAS,YAAY,CAAC,GAAc;IAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QACvB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAE5B,IAAI,SAAmB,CAAC;QAExB,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC/C,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QACtD,MAAM,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;QAE9D,IAAI,CAAC,aAAa,IAAI,CAAC,SAAS,EAAE,CAAC;YACjC,SAAS,G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plugin } from \"unified\";\nimport type { Root } from \"mdast\";\nimport { visit, CONTINUE } from \"unist-util-visit\";\nimport GithubSlugger from \"github-slugger\";\nimport { toString } from \"mdast-util-to-string\";\n\nexport type Prettify<T> = { [K in keyof T]: T[K] } & {};\n\nexport type PartiallyRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;\n\nexport type HeadingParent =\n \"root\" | \"blockquote\" | \"footnoteDefinition\" | \"listItem\" | \"container\" | \"mdxJsxFlowElement\";\n\nexport type HeadingDepth = 1 | 2 | 3 | 4 | 5 | 6;\n\nexport type TocItem = {\n value: string;\n href: string;\n depth: HeadingDepth;\n numbering: number[];\n parent: HeadingParent;\n data?: {\n [PropertyName: string]: string | number | boolean | (string | number)[] | null | undefined;\n };\n};\n\n/**\n * tocName (default: \"toc\") - the key name which is attached into vfile.data\n * tocRef (default: []) — another way of exposing the tocItems\n * maxDepth (default: 6) — max heading depth to include in the table of contents; this is inclusive: when set to 3, level three headings are included\n * skipLevels (default: [1]) — disallowed heading levels, by default the article h1 is not expected to be in the TOC\n * skipParents (default: []) — disallow headings to be children of certain node types, (the \"root\" can not be skipped)\n * exclude — headings to skip, wrapped in new RegExp('^(' + value + ')$', 'i'); any heading matching this expression will not be present in the table of contents\n * prefix - the text that will be attached to headings as prefix, like \"text-prefix-\"\n * callback - It is a callback function to take the array of toc items as an argument\n */\nexport type FlexibleTocOptions = {\n tocName?: string;\n tocRef?: TocItem[];\n maxDepth?: HeadingDepth;\n skipLevels?: HeadingDepth[];\n skipParents?: Exclude<HeadingParent, \"root\">[];\n exclude?: string | string[];\n prefix?: string;\n callback?: (toc: TocItem[]) => undefined;\n};\n\nexport type GenerateTocItemsOptions = Pick<\n FlexibleTocOptions,\n \"maxDepth\" | \"skipLevels\" | \"skipParents\" | \"exclude\" | \"prefix\"\n>;\n\ntype PartiallyRequiredFlexibleTocOptions = Prettify<\n PartiallyRequired<\n FlexibleTocOptions,\n \"tocName\" | \"tocRef\" | \"maxDepth\" | \"skipLevels\" | \"skipParents\"\n >\n>;\n\nconst DEFAULT_SETTINGS: FlexibleTocOptions = {\n tocName: \"toc\",\n tocRef: [],\n maxDepth: 6,\n skipLevels: [1],\n skipParents: [],\n};\n\n/**\n * adds numberings to the TOC items.\n * why \"number[]\"? It is because up to you joining with dot or dash or slicing the first number (reserved for h1)\n *\n * [1]\n * [1,1]\n * [1,2]\n * [1,2,1]\n */\nfunction addNumbering(arr: TocItem[]) {\n for (let i = 0; i < arr.length; i++) {\n const tocItem = arr[i];\n const depth = tocItem.depth;\n\n let numbering: number[];\n\n const prevObj = i > 0 ? arr[i - 1] : undefined;\n const prevDepth = prevObj ? prevObj.depth : undefined;\n const prevNumbering = prevObj ? prevObj.numbering : undefined;\n\n if (!prevNumbering || !prevDepth) {\n numbering = Array.from({ length: depth }, () => 1);\n } else if (depth === prevDepth) {\n numbering = [...prevNumbering];\n numbering[depth - 1]++;\n } else if (depth > prevDepth) {\n numbering = [\n ...prevNumbering,\n ...(Array.from(\n { length: depth - prevDepth }, // if depth is more bigger than prevDepth, put more \"1\" inside the array\n () => 1,\n ) as HeadingDepth[]),\n ];\n } else {\n // if (depth < prevDepth)\n numbering = prevNumbering.slice(0, depth);\n numbering[depth - 1]++;\n }\n\n tocItem.numbering = numbering;\n }\n}\n\nexport function generateTocItemsFromMdast(\n tree: Root,\n options?: GenerateTocItemsOptions,\n): TocItem[] {\n const settings = Object.assign(\n {},\n DEFAULT_SETTINGS,\n options,\n ) as PartiallyRequiredFlexibleTocOptions;\n\n const exludeRegexFilter =\n settings.exclude &&\n (Array.isArray(settings.exclude)\n ? new RegExp(\"^(\" + settings.exclude.join(\"|\") + \")$\", \"i\")\n : new RegExp(\"^(\" + settings.exclude + \")$\", \"i\"));\n\n const slugger = new GithubSlugger();\n const tocItems: TocItem[] = [];\n\n visit(tree, \"heading\", (_node, _index, _parent) => {\n /* v8 ignore next -- @preserve */\n if (!_parent || typeof _index === \"undefined\") return;\n\n const depth = _node.depth;\n const value = toString(_node, { includeImageAlt: false });\n let href = `#${settings.prefix ?? \"\"}${slugger.slug(value)}`;\n const parent = _parent.type;\n\n // maxDepth check\n if (depth > settings.maxDepth) return CONTINUE;\n\n // skipLevels check\n if (settings.skipLevels.includes(depth)) return CONTINUE;\n\n // skipParents check\n if (parent !== \"root\" && settings.skipParents.includes(parent)) return CONTINUE;\n\n // exclude check\n if (exludeRegexFilter && exludeRegexFilter.test(value)) return CONTINUE;\n\n // Other remark plugins can store custom data in node.data.hProperties\n // I omitted node.data.hName and node.data.hChildren since not related with toc\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore, vscode resolves the type but tsc build raises an error awkwardly, saying \"hProperties\" does not exist in \"HeadingData\".\n const hProperties = _node.data?.hProperties;\n const data = hProperties ? { ...hProperties } : undefined;\n\n if (data?.[\"id\"]) href = `#${data[\"id\"]}`;\n\n tocItems.push({\n value,\n href,\n depth,\n numbering: [],\n parent,\n ...(data && { data }),\n });\n\n return CONTINUE;\n });\n\n addNumbering(tocItems);\n\n return tocItems;\n}\n\nconst RemarkFlexibleToc: Plugin<[FlexibleTocOptions?], Root> = (options) => {\n const settings = Object.assign(\n {},\n DEFAULT_SETTINGS,\n options,\n ) as PartiallyRequiredFlexibleTocOptions;\n\n return (tree, file) => {\n const tocItems = generateTocItemsFromMdast(tree, options);\n\n // it is allowed to modify the TOC in the callback\n settings.callback?.(tocItems);\n\n // method - 1 for exposing the data via vfile.data **************************\n\n // other plugins are not allowed to mutate the exposed TOC\n // The spreading is slower than push but need to fresh copy\n file.data[settings.tocName] = [...tocItems];\n\n // method - 2 for exposing the data via reference array *********************\n\n if (options?.tocRef) {\n // prevent dublication if the plugin is called more than once\n settings.tocRef.length = 0;\n\n tocItems.forEach((tocItem) => {\n // the tocRef is not allowed to mutate the vfile.data.toc\n settings.tocRef.push(tocItem);\n });\n }\n };\n};\n\nexport default RemarkFlexibleToc;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remark-flexible-toc",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "Remark plugin to expose the table of contents via Vfile.data or via an option reference",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -54,15 +54,16 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@eslint/js": "^10.0.1",
|
|
57
|
-
"@types/node": "^26.
|
|
58
|
-
"@vitest/coverage-v8": "^4.1.
|
|
57
|
+
"@types/node": "^26.6.5",
|
|
58
|
+
"@vitest/coverage-v8": "^4.1.12",
|
|
59
59
|
"@vitest/eslint-plugin": "^1.6.27",
|
|
60
60
|
"dedent": "^1.7.2",
|
|
61
|
-
"eslint": "^10.
|
|
61
|
+
"eslint": "^10.13.0",
|
|
62
62
|
"eslint-config-prettier": "^10.1.8",
|
|
63
|
-
"eslint-plugin-prettier": "^5.5.
|
|
64
|
-
"globals": "^17.
|
|
65
|
-
"
|
|
63
|
+
"eslint-plugin-prettier": "^5.5.7",
|
|
64
|
+
"globals": "^17.13.0",
|
|
65
|
+
"mdast-util-from-markdown": "^2.1.0",
|
|
66
|
+
"prettier": "^3.9.10",
|
|
66
67
|
"rehype-format": "^5.0.1",
|
|
67
68
|
"rehype-stringify": "^10.0.1",
|
|
68
69
|
"remark-custom-header-id": "^1.0.0",
|
|
@@ -70,11 +71,11 @@
|
|
|
70
71
|
"remark-parse": "^11.0.0",
|
|
71
72
|
"remark-rehype": "^11.1.2",
|
|
72
73
|
"rimraf": "^6.1.3",
|
|
73
|
-
"type-coverage": "^2.30.
|
|
74
|
+
"type-coverage": "^2.30.4",
|
|
74
75
|
"typescript": "^5.9.3",
|
|
75
|
-
"typescript-eslint": "^8.
|
|
76
|
+
"typescript-eslint": "^8.71.2",
|
|
76
77
|
"unified": "^11.0.5",
|
|
77
|
-
"vitest": "^4.1.
|
|
78
|
+
"vitest": "^4.1.12"
|
|
78
79
|
},
|
|
79
80
|
"dependencies": {
|
|
80
81
|
"@types/mdast": "^4.0.4",
|