@mdit-vue/plugin-headers 3.0.1 → 4.0.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/README.md +2 -2
- package/dist/index.d.ts +5 -12
- package/dist/index.js +3 -6
- package/package.json +22 -24
package/README.md
CHANGED
|
@@ -17,13 +17,13 @@ npm i @mdit-vue/plugin-headers
|
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
19
|
import { headersPlugin } from '@mdit-vue/plugin-headers';
|
|
20
|
-
import type {
|
|
20
|
+
import type { Env } from 'markdown-it';
|
|
21
21
|
import MarkdownIt from 'markdown-it';
|
|
22
22
|
|
|
23
23
|
const md = MarkdownIt({ html: true }).use(headersPlugin, {
|
|
24
24
|
// options
|
|
25
25
|
});
|
|
26
|
-
const env:
|
|
26
|
+
const env: Env = {};
|
|
27
27
|
|
|
28
28
|
const rendered = md.render(
|
|
29
29
|
`\
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MarkdownItHeader } from "@mdit-vue/types";
|
|
3
|
-
|
|
4
|
-
//#region src/types.d.ts
|
|
5
|
-
|
|
1
|
+
import { MarkdownItHeader, MarkdownItPlugin } from "@mdit-vue/types";
|
|
6
2
|
/**
|
|
7
3
|
* Options of @mdit-vue/plugin-headers
|
|
8
4
|
*/
|
|
@@ -36,21 +32,18 @@ interface HeadersPluginOptions {
|
|
|
36
32
|
*/
|
|
37
33
|
shouldAllowNested?: boolean;
|
|
38
34
|
}
|
|
39
|
-
declare module '
|
|
40
|
-
interface
|
|
35
|
+
declare module 'markdown-it' {
|
|
36
|
+
interface Env {
|
|
41
37
|
/**
|
|
42
38
|
* The headers that extracted by `@mdit-vue/plugin-headers`
|
|
43
39
|
*/
|
|
44
40
|
headers?: MarkdownItHeader[];
|
|
45
41
|
}
|
|
46
42
|
}
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/headers-plugin.d.ts
|
|
49
43
|
/**
|
|
50
44
|
* Get markdown headers info
|
|
51
45
|
*
|
|
52
46
|
* Extract them into env
|
|
53
47
|
*/
|
|
54
|
-
declare const headersPlugin:
|
|
55
|
-
|
|
56
|
-
export { HeadersPluginOptions, type MarkdownItHeader, headersPlugin };
|
|
48
|
+
export declare const headersPlugin: MarkdownItPlugin<HeadersPluginOptions>;
|
|
49
|
+
export type { HeadersPluginOptions, MarkdownItHeader };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { resolveHeadersFromTokens, slugify } from "@mdit-vue/shared";
|
|
2
|
-
|
|
3
|
-
//#region src/headers-plugin.ts
|
|
2
|
+
// src/headers-plugin.ts
|
|
4
3
|
/**
|
|
5
4
|
* Get markdown headers info
|
|
6
5
|
*
|
|
@@ -8,7 +7,7 @@ import { resolveHeadersFromTokens, slugify } from "@mdit-vue/shared";
|
|
|
8
7
|
*/
|
|
9
8
|
const headersPlugin = (md, { level = [2, 3], shouldAllowNested = false, slugify: slugify$1 = slugify, format } = {}) => {
|
|
10
9
|
const render = md.renderer.render.bind(md.renderer);
|
|
11
|
-
md.renderer.render = (tokens, options, env) => {
|
|
10
|
+
md.renderer.render = (tokens, options, env = {}) => {
|
|
12
11
|
env.headers = resolveHeadersFromTokens(tokens, {
|
|
13
12
|
level,
|
|
14
13
|
shouldAllowHtml: false,
|
|
@@ -20,6 +19,4 @@ const headersPlugin = (md, { level = [2, 3], shouldAllowNested = false, slugify:
|
|
|
20
19
|
return render(tokens, options, env);
|
|
21
20
|
};
|
|
22
21
|
};
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
export { headersPlugin };
|
|
22
|
+
export { headersPlugin };
|
package/package.json
CHANGED
|
@@ -1,55 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdit-vue/plugin-headers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "A markdown-it plugin to get markdown headers",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"header",
|
|
7
|
+
"heading",
|
|
6
8
|
"markdown-it",
|
|
7
9
|
"markdown-it-plugin",
|
|
8
|
-
"vue"
|
|
9
|
-
"header",
|
|
10
|
-
"heading"
|
|
10
|
+
"vue"
|
|
11
11
|
],
|
|
12
12
|
"homepage": "https://github.com/mdit-vue",
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/mdit-vue/mdit-vue/issues"
|
|
15
15
|
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "meteorlxy <meteor.lxy@foxmail.com>",
|
|
16
18
|
"repository": {
|
|
17
19
|
"type": "git",
|
|
18
20
|
"url": "git+https://github.com/mdit-vue/mdit-vue.git"
|
|
19
21
|
},
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
+
"files": [
|
|
23
|
+
"./dist"
|
|
24
|
+
],
|
|
22
25
|
"type": "module",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
23
27
|
"exports": {
|
|
24
28
|
".": "./dist/index.js",
|
|
25
29
|
"./package.json": "./package.json"
|
|
26
30
|
},
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"files": [
|
|
31
|
-
"./dist"
|
|
32
|
-
],
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
33
34
|
"scripts": {
|
|
34
35
|
"build": "tsdown",
|
|
36
|
+
"clean": "rimraf ./dist",
|
|
35
37
|
"test": "vitest"
|
|
36
38
|
},
|
|
37
39
|
"dependencies": {
|
|
38
|
-
"@mdit-vue/shared": "
|
|
39
|
-
"@mdit-vue/types": "
|
|
40
|
-
"
|
|
41
|
-
"markdown-it": "^14.1.0"
|
|
40
|
+
"@mdit-vue/shared": "4.0.0",
|
|
41
|
+
"@mdit-vue/types": "4.0.0",
|
|
42
|
+
"markdown-it": "^15.0.3"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"markdown-it-anchor": "^
|
|
45
|
-
"tsdown": "^0.
|
|
46
|
-
"vitest": "^
|
|
45
|
+
"markdown-it-anchor": "^10.1.0",
|
|
46
|
+
"tsdown": "^0.23.7",
|
|
47
|
+
"vitest": "^5.1.0"
|
|
47
48
|
},
|
|
48
49
|
"engines": {
|
|
49
|
-
"node": ">=20.
|
|
50
|
-
},
|
|
51
|
-
"publishConfig": {
|
|
52
|
-
"access": "public"
|
|
50
|
+
"node": ">=20.19.0"
|
|
53
51
|
},
|
|
54
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "62f17856a1a5dec0e33c6487453a927b82a5883b"
|
|
55
53
|
}
|