@mdit-vue/plugin-toc 0.3.1 → 0.4.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/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.4.0](https://github.com/mdit-vue/mdit-vue/compare/v0.3.1...v0.4.0) (2022-07-02)
7
+
8
+ **Note:** Version bump only for package @mdit-vue/plugin-toc
9
+
6
10
  ## [0.3.1](https://github.com/mdit-vue/mdit-vue/compare/v0.3.0...v0.3.1) (2022-06-25)
7
11
 
8
12
  ### Bug Fixes
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # @mdit-vue/plugin-toc
2
2
 
3
3
  [![npm](https://badgen.net/npm/v/@mdit-vue/plugin-toc)](https://www.npmjs.com/package/@mdit-vue/plugin-toc)
4
+ [![license](https://badgen.net/github/license/mdit-vue/mdit-vue)](https://github.com/mdit-vue/mdit-vue/blob/main/LICENSE)
4
5
 
5
6
  A [markdown-it](https://github.com/markdown-it/markdown-it) plugin to generate table-of-contents (TOC) that compatible with [Vue.js](https://vuejs.org).
6
7
 
package/dist/index.d.ts CHANGED
@@ -8,6 +8,8 @@ import { PluginWithOptions } from 'markdown-it';
8
8
  interface TocPluginOptions {
9
9
  /**
10
10
  * The pattern serving as the TOC placeholder in your markdown
11
+ *
12
+ * @default /^\[\[toc\]\]$/i
11
13
  */
12
14
  pattern?: RegExp;
13
15
  /**
@@ -26,34 +28,50 @@ interface TocPluginOptions {
26
28
  *
27
29
  * Should be a subset of markdown-it-anchor's `level` option
28
30
  * to ensure the link is existed
31
+ *
32
+ * @default [2,3]
29
33
  */
30
34
  level?: number[];
31
35
  /**
32
36
  * HTML tag of the TOC container
37
+ *
38
+ * @default 'nav'
33
39
  */
34
40
  containerTag?: string;
35
41
  /**
36
42
  * The class for the TOC container
43
+ *
44
+ * @default 'table-of-contents'
37
45
  */
38
46
  containerClass?: string;
39
47
  /**
40
48
  * HTML tag of the TOC list
49
+ *
50
+ * @default 'ul'
41
51
  */
42
52
  listTag?: 'ul' | 'ol';
43
53
  /**
44
54
  * The class for the TOC list
55
+ *
56
+ * @default ''
45
57
  */
46
58
  listClass?: string;
47
59
  /**
48
60
  * The class for the `<li>` tag
61
+ *
62
+ * @default ''
49
63
  */
50
64
  itemClass?: string;
51
65
  /**
52
66
  * The tag of the link inside `<li>` tag
67
+ *
68
+ * @default 'a'
53
69
  */
54
70
  linkTag?: 'a' | 'router-link';
55
71
  /**
56
72
  * The class for the link inside the `<li>` tag
73
+ *
74
+ * @default ''
57
75
  */
58
76
  linkClass?: string;
59
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdit-vue/plugin-toc",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "A markdown-it plugin to generate table-of-contents that compatible with Vue.js",
5
5
  "keywords": [
6
6
  "markdown-it",
@@ -34,7 +34,7 @@
34
34
  "test": "vitest"
35
35
  },
36
36
  "dependencies": {
37
- "@mdit-vue/shared": "0.3.0",
37
+ "@mdit-vue/shared": "0.4.0",
38
38
  "@types/markdown-it": "^12.2.3",
39
39
  "markdown-it": "^13.0.1"
40
40
  },
@@ -42,10 +42,10 @@
42
42
  "c8": "^7.11.3",
43
43
  "markdown-it-anchor": "^8.6.4",
44
44
  "unbuild": "^0.7.4",
45
- "vitest": "^0.15.2"
45
+ "vitest": "^0.16.0"
46
46
  },
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "gitHead": "329b3e1c4b874ad07e838a93968ecbac3a333253"
50
+ "gitHead": "744887e6f4733af8da2045625e72a476947cfc25"
51
51
  }
package/src/types.ts CHANGED
@@ -4,6 +4,8 @@
4
4
  export interface TocPluginOptions {
5
5
  /**
6
6
  * The pattern serving as the TOC placeholder in your markdown
7
+ *
8
+ * @default /^\[\[toc\]\]$/i
7
9
  */
8
10
  pattern?: RegExp;
9
11
 
@@ -25,41 +27,57 @@ export interface TocPluginOptions {
25
27
  *
26
28
  * Should be a subset of markdown-it-anchor's `level` option
27
29
  * to ensure the link is existed
30
+ *
31
+ * @default [2,3]
28
32
  */
29
33
  level?: number[];
30
34
 
31
35
  /**
32
36
  * HTML tag of the TOC container
37
+ *
38
+ * @default 'nav'
33
39
  */
34
40
  containerTag?: string;
35
41
 
36
42
  /**
37
43
  * The class for the TOC container
44
+ *
45
+ * @default 'table-of-contents'
38
46
  */
39
47
  containerClass?: string;
40
48
 
41
49
  /**
42
50
  * HTML tag of the TOC list
51
+ *
52
+ * @default 'ul'
43
53
  */
44
54
  listTag?: 'ul' | 'ol';
45
55
 
46
56
  /**
47
57
  * The class for the TOC list
58
+ *
59
+ * @default ''
48
60
  */
49
61
  listClass?: string;
50
62
 
51
63
  /**
52
64
  * The class for the `<li>` tag
65
+ *
66
+ * @default ''
53
67
  */
54
68
  itemClass?: string;
55
69
 
56
70
  /**
57
71
  * The tag of the link inside `<li>` tag
72
+ *
73
+ * @default 'a'
58
74
  */
59
75
  linkTag?: 'a' | 'router-link';
60
76
 
61
77
  /**
62
78
  * The class for the link inside the `<li>` tag
79
+ *
80
+ * @default ''
63
81
  */
64
82
  linkClass?: string;
65
83
  }
@@ -1,6 +1,6 @@
1
1
  // Vitest Snapshot v1
2
2
 
3
- exports[`@vuepress/markdown > plugins > tocPlugin > should render class name correctly > complexTree 1`] = `
3
+ exports[`@mdit-vue/plugin-toc > toc-plugin > should render class name correctly > complexTree 1`] = `
4
4
  "<nav><ul class=\\"toc-list\\"><li class=\\"toc-item\\" class=\\"toc-item\\"><a class=\\"toc-link\\" href=\\"#s1-1\\">s1-1</a><ul class=\\"toc-list\\"><li class=\\"toc-item\\" class=\\"toc-item\\"><a class=\\"toc-link\\" href=\\"#s1-1-1\\">s1-1-1</a></li><li class=\\"toc-item\\" class=\\"toc-item\\"><a class=\\"toc-link\\" href=\\"#s1-1-2\\">s1-1-2</a></li><li class=\\"toc-item\\" class=\\"toc-item\\"><a class=\\"toc-link\\" href=\\"#s1-1-3\\">s1-1-3</a></li></ul></li><li class=\\"toc-item\\" class=\\"toc-item\\"><a class=\\"toc-link\\" href=\\"#s1-2\\">s1-2</a></li><li class=\\"toc-item\\" class=\\"toc-item\\"><a class=\\"toc-link\\" href=\\"#s1-3\\">s1-3</a><ul class=\\"toc-list\\"><li class=\\"toc-item\\" class=\\"toc-item\\"><a class=\\"toc-link\\" href=\\"#s1-3-2\\">s1-3-2</a></li></ul></li></ul></nav>
5
5
  <h1>s1</h1>
6
6
  <h2>s1-1</h2>
@@ -18,7 +18,7 @@ exports[`@vuepress/markdown > plugins > tocPlugin > should render class name cor
18
18
  "
19
19
  `;
20
20
 
21
- exports[`@vuepress/markdown > plugins > tocPlugin > should render class name correctly > reversedTree 1`] = `
21
+ exports[`@mdit-vue/plugin-toc > toc-plugin > should render class name correctly > reversedTree 1`] = `
22
22
  "<nav><ul class=\\"toc-list\\"><li class=\\"toc-item\\" class=\\"toc-item\\"><a class=\\"toc-link\\" href=\\"#h3\\">h3</a></li><li class=\\"toc-item\\" class=\\"toc-item\\"><a class=\\"toc-link\\" href=\\"#h2\\">h2</a></li></ul></nav>
23
23
  <h6>h6</h6>
24
24
  <h5>h5</h5>
@@ -29,7 +29,7 @@ exports[`@vuepress/markdown > plugins > tocPlugin > should render class name cor
29
29
  "
30
30
  `;
31
31
 
32
- exports[`@vuepress/markdown > plugins > tocPlugin > should render class name correctly > simpleTree 1`] = `
32
+ exports[`@mdit-vue/plugin-toc > toc-plugin > should render class name correctly > simpleTree 1`] = `
33
33
  "<nav><ul class=\\"toc-list\\"><li class=\\"toc-item\\" class=\\"toc-item\\"><a class=\\"toc-link\\" href=\\"#h2\\">h2</a><ul class=\\"toc-list\\"><li class=\\"toc-item\\" class=\\"toc-item\\"><a class=\\"toc-link\\" href=\\"#h3\\">h3</a></li></ul></li></ul></nav>
34
34
  <h1>h1</h1>
35
35
  <h2>h2</h2>
@@ -40,7 +40,7 @@ exports[`@vuepress/markdown > plugins > tocPlugin > should render class name cor
40
40
  "
41
41
  `;
42
42
 
43
- exports[`@vuepress/markdown > plugins > tocPlugin > should render toc (h1, h2, h3, h4) > complexTree 1`] = `
43
+ exports[`@mdit-vue/plugin-toc > toc-plugin > should render toc (h1, h2, h3, h4) > complexTree 1`] = `
44
44
  "<nav class=\\"table-of-contents\\"><ul><li><a href=\\"#s1\\">s1</a><ul><li><a href=\\"#s1-1\\">s1-1</a><ul><li><a href=\\"#s1-1-1\\">s1-1-1</a><ul><li><a href=\\"#s1-1-1-1\\">s1-1-1-1</a></li></ul></li><li><a href=\\"#s1-1-2\\">s1-1-2</a></li><li><a href=\\"#s1-1-3\\">s1-1-3</a><ul><li><a href=\\"#s1-1-3-1\\">s1-1-3-1</a></li></ul></li></ul></li><li><a href=\\"#s1-2\\">s1-2</a></li><li><a href=\\"#s1-3\\">s1-3</a><ul><li><a href=\\"#s1-3-2\\">s1-3-2</a><ul><li><a href=\\"#s1-3-2-1\\">s1-3-2-1</a></li></ul></li></ul></li></ul></li></ul></nav>
45
45
  <h1>s1</h1>
46
46
  <h2>s1-1</h2>
@@ -58,7 +58,7 @@ exports[`@vuepress/markdown > plugins > tocPlugin > should render toc (h1, h2, h
58
58
  "
59
59
  `;
60
60
 
61
- exports[`@vuepress/markdown > plugins > tocPlugin > should render toc (h1, h2, h3, h4) > reversedTree 1`] = `
61
+ exports[`@mdit-vue/plugin-toc > toc-plugin > should render toc (h1, h2, h3, h4) > reversedTree 1`] = `
62
62
  "<nav class=\\"table-of-contents\\"><ul><li><a href=\\"#h4\\">h4</a></li><li><a href=\\"#h3\\">h3</a></li><li><a href=\\"#h2\\">h2</a></li><li><a href=\\"#h1\\">h1</a></li></ul></nav>
63
63
  <h6>h6</h6>
64
64
  <h5>h5</h5>
@@ -69,7 +69,7 @@ exports[`@vuepress/markdown > plugins > tocPlugin > should render toc (h1, h2, h
69
69
  "
70
70
  `;
71
71
 
72
- exports[`@vuepress/markdown > plugins > tocPlugin > should render toc (h1, h2, h3, h4) > simpleTree 1`] = `
72
+ exports[`@mdit-vue/plugin-toc > toc-plugin > should render toc (h1, h2, h3, h4) > simpleTree 1`] = `
73
73
  "<nav class=\\"table-of-contents\\"><ul><li><a href=\\"#h1\\">h1</a><ul><li><a href=\\"#h2\\">h2</a><ul><li><a href=\\"#h3\\">h3</a><ul><li><a href=\\"#h4\\">h4</a></li></ul></li></ul></li></ul></li></ul></nav>
74
74
  <h1>h1</h1>
75
75
  <h2>h2</h2>
@@ -80,7 +80,7 @@ exports[`@vuepress/markdown > plugins > tocPlugin > should render toc (h1, h2, h
80
80
  "
81
81
  `;
82
82
 
83
- exports[`@vuepress/markdown > plugins > tocPlugin > should render toc with RouterLink > complexTree 1`] = `
83
+ exports[`@mdit-vue/plugin-toc > toc-plugin > should render toc with RouterLink > complexTree 1`] = `
84
84
  "<nav class=\\"table-of-contents\\"><ul><li><RouterLink href=\\"#s1-1\\">s1-1</RouterLink><ul><li><RouterLink href=\\"#s1-1-1\\">s1-1-1</RouterLink></li><li><RouterLink href=\\"#s1-1-2\\">s1-1-2</RouterLink></li><li><RouterLink href=\\"#s1-1-3\\">s1-1-3</RouterLink></li></ul></li><li><RouterLink href=\\"#s1-2\\">s1-2</RouterLink></li><li><RouterLink href=\\"#s1-3\\">s1-3</RouterLink><ul><li><RouterLink href=\\"#s1-3-2\\">s1-3-2</RouterLink></li></ul></li></ul></nav>
85
85
  <h1>s1</h1>
86
86
  <h2>s1-1</h2>
@@ -98,7 +98,7 @@ exports[`@vuepress/markdown > plugins > tocPlugin > should render toc with Route
98
98
  "
99
99
  `;
100
100
 
101
- exports[`@vuepress/markdown > plugins > tocPlugin > should render toc with RouterLink > reversedTree 1`] = `
101
+ exports[`@mdit-vue/plugin-toc > toc-plugin > should render toc with RouterLink > reversedTree 1`] = `
102
102
  "<nav class=\\"table-of-contents\\"><ul><li><RouterLink href=\\"#h3\\">h3</RouterLink></li><li><RouterLink href=\\"#h2\\">h2</RouterLink></li></ul></nav>
103
103
  <h6>h6</h6>
104
104
  <h5>h5</h5>
@@ -109,7 +109,7 @@ exports[`@vuepress/markdown > plugins > tocPlugin > should render toc with Route
109
109
  "
110
110
  `;
111
111
 
112
- exports[`@vuepress/markdown > plugins > tocPlugin > should render toc with RouterLink > simpleTree 1`] = `
112
+ exports[`@mdit-vue/plugin-toc > toc-plugin > should render toc with RouterLink > simpleTree 1`] = `
113
113
  "<nav class=\\"table-of-contents\\"><ul><li><RouterLink href=\\"#h2\\">h2</RouterLink><ul><li><RouterLink href=\\"#h3\\">h3</RouterLink></li></ul></li></ul></nav>
114
114
  <h1>h1</h1>
115
115
  <h2>h2</h2>
@@ -120,7 +120,7 @@ exports[`@vuepress/markdown > plugins > tocPlugin > should render toc with Route
120
120
  "
121
121
  `;
122
122
 
123
- exports[`@vuepress/markdown > plugins > tocPlugin > should render toc with default option (h2, h3) > complexTree 1`] = `
123
+ exports[`@mdit-vue/plugin-toc > toc-plugin > should render toc with default option (h2, h3) > complexTree 1`] = `
124
124
  "<nav class=\\"table-of-contents\\"><ul><li><a href=\\"#s1-1\\">s1-1</a><ul><li><a href=\\"#s1-1-1\\">s1-1-1</a></li><li><a href=\\"#s1-1-2\\">s1-1-2</a></li><li><a href=\\"#s1-1-3\\">s1-1-3</a></li></ul></li><li><a href=\\"#s1-2\\">s1-2</a></li><li><a href=\\"#s1-3\\">s1-3</a><ul><li><a href=\\"#s1-3-2\\">s1-3-2</a></li></ul></li></ul></nav>
125
125
  <h1>s1</h1>
126
126
  <h2>s1-1</h2>
@@ -138,7 +138,7 @@ exports[`@vuepress/markdown > plugins > tocPlugin > should render toc with defau
138
138
  "
139
139
  `;
140
140
 
141
- exports[`@vuepress/markdown > plugins > tocPlugin > should render toc with default option (h2, h3) > reversedTree 1`] = `
141
+ exports[`@mdit-vue/plugin-toc > toc-plugin > should render toc with default option (h2, h3) > reversedTree 1`] = `
142
142
  "<nav class=\\"table-of-contents\\"><ul><li><a href=\\"#h3\\">h3</a></li><li><a href=\\"#h2\\">h2</a></li></ul></nav>
143
143
  <h6>h6</h6>
144
144
  <h5>h5</h5>
@@ -149,7 +149,7 @@ exports[`@vuepress/markdown > plugins > tocPlugin > should render toc with defau
149
149
  "
150
150
  `;
151
151
 
152
- exports[`@vuepress/markdown > plugins > tocPlugin > should render toc with default option (h2, h3) > simpleTree 1`] = `
152
+ exports[`@mdit-vue/plugin-toc > toc-plugin > should render toc with default option (h2, h3) > simpleTree 1`] = `
153
153
  "<nav class=\\"table-of-contents\\"><ul><li><a href=\\"#h2\\">h2</a><ul><li><a href=\\"#h3\\">h3</a></li></ul></li></ul></nav>
154
154
  <h1>h1</h1>
155
155
  <h2>h2</h2>
@@ -41,7 +41,7 @@ const fixtures = {
41
41
  `,
42
42
  };
43
43
 
44
- describe('@vuepress/markdown > plugins > tocPlugin', () => {
44
+ describe('@mdit-vue/plugin-toc > toc-plugin', () => {
45
45
  describe('should render toc with default option (h2, h3)', () => {
46
46
  const md = MarkdownIt().use(tocPlugin);
47
47