@mdit-vue/plugin-toc 3.0.0 → 3.0.2
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 +100 -87
- package/package.json +10 -12
- package/dist/index.cjs +0 -120
- package/dist/index.d.cts +0 -123
- package/dist/index.d.mts +0 -123
- /package/dist/{index.mjs → index.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,92 +1,101 @@
|
|
|
1
|
-
import { MarkdownItHeader } from
|
|
2
|
-
import { RuleBlock } from
|
|
3
|
-
import { PluginWithOptions } from
|
|
1
|
+
import { MarkdownItHeader } from "@mdit-vue/types";
|
|
2
|
+
import { RuleBlock } from "markdown-it/lib/parser_block.mjs";
|
|
3
|
+
import { PluginWithOptions } from "markdown-it";
|
|
4
4
|
|
|
5
|
+
//#region src/types.d.ts
|
|
5
6
|
/**
|
|
6
7
|
* Options of @mdit-vue/plugin-toc
|
|
7
8
|
*/
|
|
8
9
|
interface TocPluginOptions {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The pattern serving as the TOC placeholder in your markdown
|
|
12
|
+
*
|
|
13
|
+
* @default /^\[\[toc\]\]$/i
|
|
14
|
+
*/
|
|
15
|
+
pattern?: RegExp;
|
|
16
|
+
/**
|
|
17
|
+
* A custom slugification function
|
|
18
|
+
*
|
|
19
|
+
* Should use the same slugify function with markdown-it-anchor
|
|
20
|
+
* to ensure the link is matched
|
|
21
|
+
*/
|
|
22
|
+
slugify?: (str: string) => string;
|
|
23
|
+
/**
|
|
24
|
+
* A function for formatting headings
|
|
25
|
+
*/
|
|
26
|
+
format?: (str: string) => string;
|
|
27
|
+
/**
|
|
28
|
+
* Heading level that going to be included in the TOC
|
|
29
|
+
*
|
|
30
|
+
* Should be a subset of markdown-it-anchor's `level` option
|
|
31
|
+
* to ensure the link is existed
|
|
32
|
+
*
|
|
33
|
+
* @default [2,3]
|
|
34
|
+
*/
|
|
35
|
+
level?: number[];
|
|
36
|
+
/**
|
|
37
|
+
* Should allow headers inside nested blocks or not
|
|
38
|
+
*
|
|
39
|
+
* If set to `true`, headers inside blockquote, list, etc. would also be included.
|
|
40
|
+
*
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
shouldAllowNested?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* HTML tag of the TOC container
|
|
46
|
+
*
|
|
47
|
+
* @default 'nav'
|
|
48
|
+
*/
|
|
49
|
+
containerTag?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The class for the TOC container
|
|
52
|
+
*
|
|
53
|
+
* @default 'table-of-contents'
|
|
54
|
+
*/
|
|
55
|
+
containerClass?: string;
|
|
56
|
+
/**
|
|
57
|
+
* HTML tag of the TOC list
|
|
58
|
+
*
|
|
59
|
+
* @default 'ul'
|
|
60
|
+
*/
|
|
61
|
+
listTag?: 'ol' | 'ul';
|
|
62
|
+
/**
|
|
63
|
+
* The class for the TOC list
|
|
64
|
+
*
|
|
65
|
+
* @default ''
|
|
66
|
+
*/
|
|
67
|
+
listClass?: string;
|
|
68
|
+
/**
|
|
69
|
+
* The class for the `<li>` tag
|
|
70
|
+
*
|
|
71
|
+
* @default ''
|
|
72
|
+
*/
|
|
73
|
+
itemClass?: string;
|
|
74
|
+
/**
|
|
75
|
+
* The tag of the link inside `<li>` tag
|
|
76
|
+
*
|
|
77
|
+
* @default 'a'
|
|
78
|
+
*/
|
|
79
|
+
linkTag?: 'a' | 'router-link';
|
|
80
|
+
/**
|
|
81
|
+
* The class for the link inside the `<li>` tag
|
|
82
|
+
*
|
|
83
|
+
* @default ''
|
|
84
|
+
*/
|
|
85
|
+
linkClass?: string;
|
|
85
86
|
}
|
|
86
|
-
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/create-render-headers.d.ts
|
|
87
89
|
type RenderHeadersFn = (headers: MarkdownItHeader[]) => string;
|
|
88
|
-
declare const createRenderHeaders: ({
|
|
89
|
-
|
|
90
|
+
declare const createRenderHeaders: ({
|
|
91
|
+
listTag,
|
|
92
|
+
listClass,
|
|
93
|
+
itemClass,
|
|
94
|
+
linkTag,
|
|
95
|
+
linkClass
|
|
96
|
+
}: Pick<Required<TocPluginOptions>, "itemClass" | "linkClass" | "linkTag" | "listClass" | "listTag">) => RenderHeadersFn;
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/create-toc-block-rule.d.ts
|
|
90
99
|
/**
|
|
91
100
|
* Forked and modified from markdown-it-toc-done-right
|
|
92
101
|
*
|
|
@@ -95,8 +104,13 @@ declare const createRenderHeaders: ({ listTag, listClass, itemClass, linkTag, li
|
|
|
95
104
|
*
|
|
96
105
|
* @see https://github.com/nagaozen/markdown-it-toc-done-right
|
|
97
106
|
*/
|
|
98
|
-
declare const createTocBlockRule: ({
|
|
99
|
-
|
|
107
|
+
declare const createTocBlockRule: ({
|
|
108
|
+
pattern,
|
|
109
|
+
containerTag,
|
|
110
|
+
containerClass
|
|
111
|
+
}: Pick<Required<TocPluginOptions>, "containerClass" | "containerTag" | "pattern">) => RuleBlock;
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/toc-plugin.d.ts
|
|
100
114
|
/**
|
|
101
115
|
* Generate table of contents
|
|
102
116
|
*
|
|
@@ -105,6 +119,5 @@ declare const createTocBlockRule: ({ pattern, containerTag, containerClass, }: P
|
|
|
105
119
|
* @see https://github.com/nagaozen/markdown-it-toc-done-right
|
|
106
120
|
*/
|
|
107
121
|
declare const tocPlugin: PluginWithOptions<TocPluginOptions>;
|
|
108
|
-
|
|
109
|
-
export { createRenderHeaders, createTocBlockRule, tocPlugin };
|
|
110
|
-
export type { TocPluginOptions };
|
|
122
|
+
//#endregion
|
|
123
|
+
export { TocPluginOptions, createRenderHeaders, createTocBlockRule, tocPlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdit-vue/plugin-toc",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "A markdown-it plugin to generate table-of-contents that compatible with Vue.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
@@ -21,31 +21,29 @@
|
|
|
21
21
|
"author": "meteorlxy <meteor.lxy@foxmail.com>",
|
|
22
22
|
"type": "module",
|
|
23
23
|
"exports": {
|
|
24
|
-
".":
|
|
25
|
-
"import": "./dist/index.mjs",
|
|
26
|
-
"require": "./dist/index.cjs"
|
|
27
|
-
},
|
|
24
|
+
".": "./dist/index.js",
|
|
28
25
|
"./package.json": "./package.json"
|
|
29
26
|
},
|
|
30
|
-
"main": "./dist/index.
|
|
31
|
-
"module": "./dist/index.
|
|
32
|
-
"types": "./dist/index.d.
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
33
30
|
"files": [
|
|
34
31
|
"./dist"
|
|
35
32
|
],
|
|
36
33
|
"scripts": {
|
|
37
34
|
"build": "tsdown",
|
|
35
|
+
"clean": "rimraf ./dist",
|
|
38
36
|
"test": "vitest"
|
|
39
37
|
},
|
|
40
38
|
"dependencies": {
|
|
41
|
-
"@mdit-vue/shared": "3.0.
|
|
42
|
-
"@mdit-vue/types": "3.0.
|
|
39
|
+
"@mdit-vue/shared": "3.0.2",
|
|
40
|
+
"@mdit-vue/types": "3.0.2",
|
|
43
41
|
"@types/markdown-it": "^14.1.2",
|
|
44
42
|
"markdown-it": "^14.1.0"
|
|
45
43
|
},
|
|
46
44
|
"devDependencies": {
|
|
47
45
|
"markdown-it-anchor": "^9.2.0",
|
|
48
|
-
"tsdown": "^0.14.
|
|
46
|
+
"tsdown": "^0.14.1",
|
|
49
47
|
"vitest": "^3.2.4"
|
|
50
48
|
},
|
|
51
49
|
"engines": {
|
|
@@ -54,5 +52,5 @@
|
|
|
54
52
|
"publishConfig": {
|
|
55
53
|
"access": "public"
|
|
56
54
|
},
|
|
57
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "3b5332d09fbd927319bd8be3ba3b86b3d12d1ec8"
|
|
58
56
|
}
|
package/dist/index.cjs
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
const __mdit_vue_shared = __toESM(require("@mdit-vue/shared"));
|
|
25
|
-
|
|
26
|
-
//#region src/create-render-headers.ts
|
|
27
|
-
const createRenderHeaders = ({ listTag, listClass, itemClass, linkTag, linkClass }) => {
|
|
28
|
-
const listTagString = (0, __mdit_vue_shared.htmlEscape)(listTag);
|
|
29
|
-
const listClassString = listClass ? ` class="${(0, __mdit_vue_shared.htmlEscape)(listClass)}"` : "";
|
|
30
|
-
const itemTagString = "li";
|
|
31
|
-
const itemClassString = itemClass ? ` class="${(0, __mdit_vue_shared.htmlEscape)(itemClass)}"` : "";
|
|
32
|
-
const linkTagString = (0, __mdit_vue_shared.htmlEscape)(linkTag);
|
|
33
|
-
const linkClassString = linkClass ? ` class="${(0, __mdit_vue_shared.htmlEscape)(linkClass)}"` : "";
|
|
34
|
-
const linkTo = (link) => linkTag === "router-link" ? ` to="${link}"` : ` href="${link}"`;
|
|
35
|
-
const renderHeaders = (headers) => `\
|
|
36
|
-
<${listTagString}${listClassString}>\
|
|
37
|
-
${headers.map((header) => `\
|
|
38
|
-
<${itemTagString}${itemClassString}>\
|
|
39
|
-
<${linkTagString}${linkClassString}${linkTo(header.link)}>\
|
|
40
|
-
${header.title}\
|
|
41
|
-
</${linkTagString}>\
|
|
42
|
-
${header.children.length > 0 ? renderHeaders(header.children) : ""}\
|
|
43
|
-
</${itemTagString}>\
|
|
44
|
-
`).join("")}\
|
|
45
|
-
</${listTagString}>`;
|
|
46
|
-
return renderHeaders;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region src/create-toc-block-rule.ts
|
|
51
|
-
/**
|
|
52
|
-
* Forked and modified from markdown-it-toc-done-right
|
|
53
|
-
*
|
|
54
|
-
* - remove the `inlineOptions` support
|
|
55
|
-
* - use markdown-it default renderer to render token whenever possible
|
|
56
|
-
*
|
|
57
|
-
* @see https://github.com/nagaozen/markdown-it-toc-done-right
|
|
58
|
-
*/
|
|
59
|
-
const createTocBlockRule = ({ pattern, containerTag, containerClass }) => (state, startLine, endLine, silent) => {
|
|
60
|
-
if (state.sCount[startLine] - state.blkIndent >= 4) return false;
|
|
61
|
-
const pos = state.bMarks[startLine] + state.tShift[startLine];
|
|
62
|
-
const max = state.eMarks[startLine];
|
|
63
|
-
const lineFirstToken = state.src.slice(pos, max).split(" ")[0];
|
|
64
|
-
if (!pattern.test(lineFirstToken)) return false;
|
|
65
|
-
if (silent) return true;
|
|
66
|
-
state.line = startLine + 1;
|
|
67
|
-
const tokenOpen = state.push("toc_open", containerTag, 1);
|
|
68
|
-
tokenOpen.markup = "";
|
|
69
|
-
tokenOpen.map = [startLine, state.line];
|
|
70
|
-
if (containerClass) tokenOpen.attrSet("class", containerClass);
|
|
71
|
-
const tokenBody = state.push("toc_body", "", 0);
|
|
72
|
-
tokenBody.markup = lineFirstToken;
|
|
73
|
-
tokenBody.map = [startLine, state.line];
|
|
74
|
-
tokenBody.hidden = true;
|
|
75
|
-
const tokenClose = state.push("toc_close", containerTag, -1);
|
|
76
|
-
tokenClose.markup = "";
|
|
77
|
-
tokenBody.map = [startLine, state.line];
|
|
78
|
-
return true;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region src/toc-plugin.ts
|
|
83
|
-
/**
|
|
84
|
-
* Generate table of contents
|
|
85
|
-
*
|
|
86
|
-
* Forked and modified from markdown-it-toc-done-right:
|
|
87
|
-
*
|
|
88
|
-
* @see https://github.com/nagaozen/markdown-it-toc-done-right
|
|
89
|
-
*/
|
|
90
|
-
const tocPlugin = (md, { pattern = /^\[\[toc\]\]$/i, slugify = __mdit_vue_shared.slugify, format, level = [2, 3], shouldAllowNested = false, containerTag = "nav", containerClass = "table-of-contents", listTag = "ul", listClass = "", itemClass = "", linkTag = "a", linkClass = "" } = {}) => {
|
|
91
|
-
md.block.ruler.before("heading", "toc", createTocBlockRule({
|
|
92
|
-
pattern,
|
|
93
|
-
containerTag,
|
|
94
|
-
containerClass
|
|
95
|
-
}), { alt: [
|
|
96
|
-
"paragraph",
|
|
97
|
-
"reference",
|
|
98
|
-
"blockquote"
|
|
99
|
-
] });
|
|
100
|
-
const renderHeaders = createRenderHeaders({
|
|
101
|
-
listTag,
|
|
102
|
-
listClass,
|
|
103
|
-
itemClass,
|
|
104
|
-
linkTag,
|
|
105
|
-
linkClass
|
|
106
|
-
});
|
|
107
|
-
md.renderer.rules.toc_body = (tokens) => renderHeaders((0, __mdit_vue_shared.resolveHeadersFromTokens)(tokens, {
|
|
108
|
-
level,
|
|
109
|
-
shouldAllowHtml: true,
|
|
110
|
-
shouldAllowNested,
|
|
111
|
-
shouldEscapeText: true,
|
|
112
|
-
slugify,
|
|
113
|
-
format
|
|
114
|
-
}));
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
//#endregion
|
|
118
|
-
exports.createRenderHeaders = createRenderHeaders;
|
|
119
|
-
exports.createTocBlockRule = createTocBlockRule;
|
|
120
|
-
exports.tocPlugin = tocPlugin;
|
package/dist/index.d.cts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { MarkdownItHeader } from "@mdit-vue/types";
|
|
2
|
-
import { RuleBlock } from "markdown-it/lib/parser_block.mjs";
|
|
3
|
-
import { PluginWithOptions } from "markdown-it";
|
|
4
|
-
|
|
5
|
-
//#region src/types.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Options of @mdit-vue/plugin-toc
|
|
8
|
-
*/
|
|
9
|
-
interface TocPluginOptions {
|
|
10
|
-
/**
|
|
11
|
-
* The pattern serving as the TOC placeholder in your markdown
|
|
12
|
-
*
|
|
13
|
-
* @default /^\[\[toc\]\]$/i
|
|
14
|
-
*/
|
|
15
|
-
pattern?: RegExp;
|
|
16
|
-
/**
|
|
17
|
-
* A custom slugification function
|
|
18
|
-
*
|
|
19
|
-
* Should use the same slugify function with markdown-it-anchor
|
|
20
|
-
* to ensure the link is matched
|
|
21
|
-
*/
|
|
22
|
-
slugify?: (str: string) => string;
|
|
23
|
-
/**
|
|
24
|
-
* A function for formatting headings
|
|
25
|
-
*/
|
|
26
|
-
format?: (str: string) => string;
|
|
27
|
-
/**
|
|
28
|
-
* Heading level that going to be included in the TOC
|
|
29
|
-
*
|
|
30
|
-
* Should be a subset of markdown-it-anchor's `level` option
|
|
31
|
-
* to ensure the link is existed
|
|
32
|
-
*
|
|
33
|
-
* @default [2,3]
|
|
34
|
-
*/
|
|
35
|
-
level?: number[];
|
|
36
|
-
/**
|
|
37
|
-
* Should allow headers inside nested blocks or not
|
|
38
|
-
*
|
|
39
|
-
* If set to `true`, headers inside blockquote, list, etc. would also be included.
|
|
40
|
-
*
|
|
41
|
-
* @default false
|
|
42
|
-
*/
|
|
43
|
-
shouldAllowNested?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* HTML tag of the TOC container
|
|
46
|
-
*
|
|
47
|
-
* @default 'nav'
|
|
48
|
-
*/
|
|
49
|
-
containerTag?: string;
|
|
50
|
-
/**
|
|
51
|
-
* The class for the TOC container
|
|
52
|
-
*
|
|
53
|
-
* @default 'table-of-contents'
|
|
54
|
-
*/
|
|
55
|
-
containerClass?: string;
|
|
56
|
-
/**
|
|
57
|
-
* HTML tag of the TOC list
|
|
58
|
-
*
|
|
59
|
-
* @default 'ul'
|
|
60
|
-
*/
|
|
61
|
-
listTag?: 'ol' | 'ul';
|
|
62
|
-
/**
|
|
63
|
-
* The class for the TOC list
|
|
64
|
-
*
|
|
65
|
-
* @default ''
|
|
66
|
-
*/
|
|
67
|
-
listClass?: string;
|
|
68
|
-
/**
|
|
69
|
-
* The class for the `<li>` tag
|
|
70
|
-
*
|
|
71
|
-
* @default ''
|
|
72
|
-
*/
|
|
73
|
-
itemClass?: string;
|
|
74
|
-
/**
|
|
75
|
-
* The tag of the link inside `<li>` tag
|
|
76
|
-
*
|
|
77
|
-
* @default 'a'
|
|
78
|
-
*/
|
|
79
|
-
linkTag?: 'a' | 'router-link';
|
|
80
|
-
/**
|
|
81
|
-
* The class for the link inside the `<li>` tag
|
|
82
|
-
*
|
|
83
|
-
* @default ''
|
|
84
|
-
*/
|
|
85
|
-
linkClass?: string;
|
|
86
|
-
}
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region src/create-render-headers.d.ts
|
|
89
|
-
type RenderHeadersFn = (headers: MarkdownItHeader[]) => string;
|
|
90
|
-
declare const createRenderHeaders: ({
|
|
91
|
-
listTag,
|
|
92
|
-
listClass,
|
|
93
|
-
itemClass,
|
|
94
|
-
linkTag,
|
|
95
|
-
linkClass
|
|
96
|
-
}: Pick<Required<TocPluginOptions>, "itemClass" | "linkClass" | "linkTag" | "listClass" | "listTag">) => RenderHeadersFn;
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/create-toc-block-rule.d.ts
|
|
99
|
-
/**
|
|
100
|
-
* Forked and modified from markdown-it-toc-done-right
|
|
101
|
-
*
|
|
102
|
-
* - remove the `inlineOptions` support
|
|
103
|
-
* - use markdown-it default renderer to render token whenever possible
|
|
104
|
-
*
|
|
105
|
-
* @see https://github.com/nagaozen/markdown-it-toc-done-right
|
|
106
|
-
*/
|
|
107
|
-
declare const createTocBlockRule: ({
|
|
108
|
-
pattern,
|
|
109
|
-
containerTag,
|
|
110
|
-
containerClass
|
|
111
|
-
}: Pick<Required<TocPluginOptions>, "containerClass" | "containerTag" | "pattern">) => RuleBlock;
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region src/toc-plugin.d.ts
|
|
114
|
-
/**
|
|
115
|
-
* Generate table of contents
|
|
116
|
-
*
|
|
117
|
-
* Forked and modified from markdown-it-toc-done-right:
|
|
118
|
-
*
|
|
119
|
-
* @see https://github.com/nagaozen/markdown-it-toc-done-right
|
|
120
|
-
*/
|
|
121
|
-
declare const tocPlugin: PluginWithOptions<TocPluginOptions>;
|
|
122
|
-
//#endregion
|
|
123
|
-
export { TocPluginOptions, createRenderHeaders, createTocBlockRule, tocPlugin };
|
package/dist/index.d.mts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { MarkdownItHeader } from "@mdit-vue/types";
|
|
2
|
-
import { RuleBlock } from "markdown-it/lib/parser_block.mjs";
|
|
3
|
-
import { PluginWithOptions } from "markdown-it";
|
|
4
|
-
|
|
5
|
-
//#region src/types.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* Options of @mdit-vue/plugin-toc
|
|
8
|
-
*/
|
|
9
|
-
interface TocPluginOptions {
|
|
10
|
-
/**
|
|
11
|
-
* The pattern serving as the TOC placeholder in your markdown
|
|
12
|
-
*
|
|
13
|
-
* @default /^\[\[toc\]\]$/i
|
|
14
|
-
*/
|
|
15
|
-
pattern?: RegExp;
|
|
16
|
-
/**
|
|
17
|
-
* A custom slugification function
|
|
18
|
-
*
|
|
19
|
-
* Should use the same slugify function with markdown-it-anchor
|
|
20
|
-
* to ensure the link is matched
|
|
21
|
-
*/
|
|
22
|
-
slugify?: (str: string) => string;
|
|
23
|
-
/**
|
|
24
|
-
* A function for formatting headings
|
|
25
|
-
*/
|
|
26
|
-
format?: (str: string) => string;
|
|
27
|
-
/**
|
|
28
|
-
* Heading level that going to be included in the TOC
|
|
29
|
-
*
|
|
30
|
-
* Should be a subset of markdown-it-anchor's `level` option
|
|
31
|
-
* to ensure the link is existed
|
|
32
|
-
*
|
|
33
|
-
* @default [2,3]
|
|
34
|
-
*/
|
|
35
|
-
level?: number[];
|
|
36
|
-
/**
|
|
37
|
-
* Should allow headers inside nested blocks or not
|
|
38
|
-
*
|
|
39
|
-
* If set to `true`, headers inside blockquote, list, etc. would also be included.
|
|
40
|
-
*
|
|
41
|
-
* @default false
|
|
42
|
-
*/
|
|
43
|
-
shouldAllowNested?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* HTML tag of the TOC container
|
|
46
|
-
*
|
|
47
|
-
* @default 'nav'
|
|
48
|
-
*/
|
|
49
|
-
containerTag?: string;
|
|
50
|
-
/**
|
|
51
|
-
* The class for the TOC container
|
|
52
|
-
*
|
|
53
|
-
* @default 'table-of-contents'
|
|
54
|
-
*/
|
|
55
|
-
containerClass?: string;
|
|
56
|
-
/**
|
|
57
|
-
* HTML tag of the TOC list
|
|
58
|
-
*
|
|
59
|
-
* @default 'ul'
|
|
60
|
-
*/
|
|
61
|
-
listTag?: 'ol' | 'ul';
|
|
62
|
-
/**
|
|
63
|
-
* The class for the TOC list
|
|
64
|
-
*
|
|
65
|
-
* @default ''
|
|
66
|
-
*/
|
|
67
|
-
listClass?: string;
|
|
68
|
-
/**
|
|
69
|
-
* The class for the `<li>` tag
|
|
70
|
-
*
|
|
71
|
-
* @default ''
|
|
72
|
-
*/
|
|
73
|
-
itemClass?: string;
|
|
74
|
-
/**
|
|
75
|
-
* The tag of the link inside `<li>` tag
|
|
76
|
-
*
|
|
77
|
-
* @default 'a'
|
|
78
|
-
*/
|
|
79
|
-
linkTag?: 'a' | 'router-link';
|
|
80
|
-
/**
|
|
81
|
-
* The class for the link inside the `<li>` tag
|
|
82
|
-
*
|
|
83
|
-
* @default ''
|
|
84
|
-
*/
|
|
85
|
-
linkClass?: string;
|
|
86
|
-
}
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region src/create-render-headers.d.ts
|
|
89
|
-
type RenderHeadersFn = (headers: MarkdownItHeader[]) => string;
|
|
90
|
-
declare const createRenderHeaders: ({
|
|
91
|
-
listTag,
|
|
92
|
-
listClass,
|
|
93
|
-
itemClass,
|
|
94
|
-
linkTag,
|
|
95
|
-
linkClass
|
|
96
|
-
}: Pick<Required<TocPluginOptions>, "itemClass" | "linkClass" | "linkTag" | "listClass" | "listTag">) => RenderHeadersFn;
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/create-toc-block-rule.d.ts
|
|
99
|
-
/**
|
|
100
|
-
* Forked and modified from markdown-it-toc-done-right
|
|
101
|
-
*
|
|
102
|
-
* - remove the `inlineOptions` support
|
|
103
|
-
* - use markdown-it default renderer to render token whenever possible
|
|
104
|
-
*
|
|
105
|
-
* @see https://github.com/nagaozen/markdown-it-toc-done-right
|
|
106
|
-
*/
|
|
107
|
-
declare const createTocBlockRule: ({
|
|
108
|
-
pattern,
|
|
109
|
-
containerTag,
|
|
110
|
-
containerClass
|
|
111
|
-
}: Pick<Required<TocPluginOptions>, "containerClass" | "containerTag" | "pattern">) => RuleBlock;
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region src/toc-plugin.d.ts
|
|
114
|
-
/**
|
|
115
|
-
* Generate table of contents
|
|
116
|
-
*
|
|
117
|
-
* Forked and modified from markdown-it-toc-done-right:
|
|
118
|
-
*
|
|
119
|
-
* @see https://github.com/nagaozen/markdown-it-toc-done-right
|
|
120
|
-
*/
|
|
121
|
-
declare const tocPlugin: PluginWithOptions<TocPluginOptions>;
|
|
122
|
-
//#endregion
|
|
123
|
-
export { TocPluginOptions, createRenderHeaders, createTocBlockRule, tocPlugin };
|
|
File without changes
|