@mdit-vue/plugin-headers 2.1.4 → 3.0.1

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