@mdit-vue/plugin-headers 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 +42 -41
- package/package.json +10 -12
- package/dist/index.cjs +0 -48
- package/dist/index.d.cts +0 -56
- package/dist/index.d.mts +0 -56
- /package/dist/{index.mjs → index.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,55 +1,56 @@
|
|
|
1
|
-
import { PluginWithOptions } from
|
|
2
|
-
import { MarkdownItHeader } from
|
|
3
|
-
|
|
1
|
+
import { PluginWithOptions } from "markdown-it";
|
|
2
|
+
import { MarkdownItHeader } from "@mdit-vue/types";
|
|
3
|
+
|
|
4
|
+
//#region src/types.d.ts
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Options of @mdit-vue/plugin-headers
|
|
7
8
|
*/
|
|
8
9
|
interface HeadersPluginOptions {
|
|
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
|
-
|
|
10
|
+
/**
|
|
11
|
+
* A custom slugification function
|
|
12
|
+
*
|
|
13
|
+
* Should use the same slugify function with markdown-it-anchor
|
|
14
|
+
* to ensure the link is matched
|
|
15
|
+
*/
|
|
16
|
+
slugify?: (str: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* A function for formatting header title
|
|
19
|
+
*/
|
|
20
|
+
format?: (str: string) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Heading level that going to be extracted
|
|
23
|
+
*
|
|
24
|
+
* Should be a subset of markdown-it-anchor's `level` option
|
|
25
|
+
* to ensure the slug is existed
|
|
26
|
+
*
|
|
27
|
+
* @default [2,3]
|
|
28
|
+
*/
|
|
29
|
+
level?: number[];
|
|
30
|
+
/**
|
|
31
|
+
* Should allow headers inside nested blocks or not
|
|
32
|
+
*
|
|
33
|
+
* If set to `true`, headers inside blockquote, list, etc. would also be extracted.
|
|
34
|
+
*
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
shouldAllowNested?: boolean;
|
|
37
38
|
}
|
|
38
39
|
declare module '@mdit-vue/types' {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
interface MarkdownItEnv {
|
|
41
|
+
/**
|
|
42
|
+
* The headers that extracted by `@mdit-vue/plugin-headers`
|
|
43
|
+
*/
|
|
44
|
+
headers?: MarkdownItHeader[];
|
|
45
|
+
}
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/headers-plugin.d.ts
|
|
47
49
|
/**
|
|
48
50
|
* Get markdown headers info
|
|
49
51
|
*
|
|
50
52
|
* Extract them into env
|
|
51
53
|
*/
|
|
52
54
|
declare const headersPlugin: PluginWithOptions<HeadersPluginOptions>;
|
|
53
|
-
|
|
54
|
-
export { headersPlugin };
|
|
55
|
-
export type { HeadersPluginOptions };
|
|
55
|
+
//#endregion
|
|
56
|
+
export { HeadersPluginOptions, type MarkdownItHeader, headersPlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdit-vue/plugin-headers",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "A markdown-it plugin to get markdown headers",
|
|
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,48 +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/headers-plugin.ts
|
|
27
|
-
/**
|
|
28
|
-
* Get markdown headers info
|
|
29
|
-
*
|
|
30
|
-
* Extract them into env
|
|
31
|
-
*/
|
|
32
|
-
const headersPlugin = (md, { level = [2, 3], shouldAllowNested = false, slugify = __mdit_vue_shared.slugify, format } = {}) => {
|
|
33
|
-
const render = md.renderer.render.bind(md.renderer);
|
|
34
|
-
md.renderer.render = (tokens, options, env) => {
|
|
35
|
-
env.headers = (0, __mdit_vue_shared.resolveHeadersFromTokens)(tokens, {
|
|
36
|
-
level,
|
|
37
|
-
shouldAllowHtml: false,
|
|
38
|
-
shouldAllowNested,
|
|
39
|
-
shouldEscapeText: false,
|
|
40
|
-
slugify,
|
|
41
|
-
format
|
|
42
|
-
});
|
|
43
|
-
return render(tokens, options, env);
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
exports.headersPlugin = headersPlugin;
|
package/dist/index.d.cts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { PluginWithOptions } from "markdown-it";
|
|
2
|
-
import { MarkdownItHeader } from "@mdit-vue/types";
|
|
3
|
-
|
|
4
|
-
//#region src/types.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Options of @mdit-vue/plugin-headers
|
|
8
|
-
*/
|
|
9
|
-
interface HeadersPluginOptions {
|
|
10
|
-
/**
|
|
11
|
-
* A custom slugification function
|
|
12
|
-
*
|
|
13
|
-
* Should use the same slugify function with markdown-it-anchor
|
|
14
|
-
* to ensure the link is matched
|
|
15
|
-
*/
|
|
16
|
-
slugify?: (str: string) => string;
|
|
17
|
-
/**
|
|
18
|
-
* A function for formatting header title
|
|
19
|
-
*/
|
|
20
|
-
format?: (str: string) => string;
|
|
21
|
-
/**
|
|
22
|
-
* Heading level that going to be extracted
|
|
23
|
-
*
|
|
24
|
-
* Should be a subset of markdown-it-anchor's `level` option
|
|
25
|
-
* to ensure the slug is existed
|
|
26
|
-
*
|
|
27
|
-
* @default [2,3]
|
|
28
|
-
*/
|
|
29
|
-
level?: number[];
|
|
30
|
-
/**
|
|
31
|
-
* Should allow headers inside nested blocks or not
|
|
32
|
-
*
|
|
33
|
-
* If set to `true`, headers inside blockquote, list, etc. would also be extracted.
|
|
34
|
-
*
|
|
35
|
-
* @default false
|
|
36
|
-
*/
|
|
37
|
-
shouldAllowNested?: boolean;
|
|
38
|
-
}
|
|
39
|
-
declare module '@mdit-vue/types' {
|
|
40
|
-
interface MarkdownItEnv {
|
|
41
|
-
/**
|
|
42
|
-
* The headers that extracted by `@mdit-vue/plugin-headers`
|
|
43
|
-
*/
|
|
44
|
-
headers?: MarkdownItHeader[];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/headers-plugin.d.ts
|
|
49
|
-
/**
|
|
50
|
-
* Get markdown headers info
|
|
51
|
-
*
|
|
52
|
-
* Extract them into env
|
|
53
|
-
*/
|
|
54
|
-
declare const headersPlugin: PluginWithOptions<HeadersPluginOptions>;
|
|
55
|
-
//#endregion
|
|
56
|
-
export { HeadersPluginOptions, type MarkdownItHeader, headersPlugin };
|
package/dist/index.d.mts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { PluginWithOptions } from "markdown-it";
|
|
2
|
-
import { MarkdownItHeader } from "@mdit-vue/types";
|
|
3
|
-
|
|
4
|
-
//#region src/types.d.ts
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Options of @mdit-vue/plugin-headers
|
|
8
|
-
*/
|
|
9
|
-
interface HeadersPluginOptions {
|
|
10
|
-
/**
|
|
11
|
-
* A custom slugification function
|
|
12
|
-
*
|
|
13
|
-
* Should use the same slugify function with markdown-it-anchor
|
|
14
|
-
* to ensure the link is matched
|
|
15
|
-
*/
|
|
16
|
-
slugify?: (str: string) => string;
|
|
17
|
-
/**
|
|
18
|
-
* A function for formatting header title
|
|
19
|
-
*/
|
|
20
|
-
format?: (str: string) => string;
|
|
21
|
-
/**
|
|
22
|
-
* Heading level that going to be extracted
|
|
23
|
-
*
|
|
24
|
-
* Should be a subset of markdown-it-anchor's `level` option
|
|
25
|
-
* to ensure the slug is existed
|
|
26
|
-
*
|
|
27
|
-
* @default [2,3]
|
|
28
|
-
*/
|
|
29
|
-
level?: number[];
|
|
30
|
-
/**
|
|
31
|
-
* Should allow headers inside nested blocks or not
|
|
32
|
-
*
|
|
33
|
-
* If set to `true`, headers inside blockquote, list, etc. would also be extracted.
|
|
34
|
-
*
|
|
35
|
-
* @default false
|
|
36
|
-
*/
|
|
37
|
-
shouldAllowNested?: boolean;
|
|
38
|
-
}
|
|
39
|
-
declare module '@mdit-vue/types' {
|
|
40
|
-
interface MarkdownItEnv {
|
|
41
|
-
/**
|
|
42
|
-
* The headers that extracted by `@mdit-vue/plugin-headers`
|
|
43
|
-
*/
|
|
44
|
-
headers?: MarkdownItHeader[];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/headers-plugin.d.ts
|
|
49
|
-
/**
|
|
50
|
-
* Get markdown headers info
|
|
51
|
-
*
|
|
52
|
-
* Extract them into env
|
|
53
|
-
*/
|
|
54
|
-
declare const headersPlugin: PluginWithOptions<HeadersPluginOptions>;
|
|
55
|
-
//#endregion
|
|
56
|
-
export { HeadersPluginOptions, type MarkdownItHeader, headersPlugin };
|
|
File without changes
|