@md-plugins/md-plugin-headers 0.1.0-alpha.26 → 0.1.0-alpha.28
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.mts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.mjs +13 -9
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -32,6 +32,22 @@ interface HeadersPluginOptions {
|
|
|
32
32
|
* @default false
|
|
33
33
|
*/
|
|
34
34
|
shouldAllowNested?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Should allow API headers
|
|
37
|
+
*
|
|
38
|
+
* If set to `true`, headers for `<MarkdownAPI>` title would also be extracted.
|
|
39
|
+
*
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
shouldAllowApi?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Should allow Example headers
|
|
45
|
+
*
|
|
46
|
+
* If set to `true`, headers for `<MarkdownExample>` title would also be extracted.
|
|
47
|
+
*
|
|
48
|
+
* @default true
|
|
49
|
+
*/
|
|
50
|
+
shouldAllowExample?: boolean;
|
|
35
51
|
}
|
|
36
52
|
interface TocItem {
|
|
37
53
|
id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,22 @@ interface HeadersPluginOptions {
|
|
|
32
32
|
* @default false
|
|
33
33
|
*/
|
|
34
34
|
shouldAllowNested?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Should allow API headers
|
|
37
|
+
*
|
|
38
|
+
* If set to `true`, headers for `<MarkdownAPI>` title would also be extracted.
|
|
39
|
+
*
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
shouldAllowApi?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Should allow Example headers
|
|
45
|
+
*
|
|
46
|
+
* If set to `true`, headers for `<MarkdownExample>` title would also be extracted.
|
|
47
|
+
*
|
|
48
|
+
* @default true
|
|
49
|
+
*/
|
|
50
|
+
shouldAllowExample?: boolean;
|
|
35
51
|
}
|
|
36
52
|
interface TocItem {
|
|
37
53
|
id: string;
|
package/dist/index.mjs
CHANGED
|
@@ -18,7 +18,9 @@ function parseContent(str, slugify$1 = slugify, format = (_str) => _str) {
|
|
|
18
18
|
const headersPlugin = (md, {
|
|
19
19
|
level = [2, 3],
|
|
20
20
|
slugify: slugify$1 = slugify,
|
|
21
|
-
format
|
|
21
|
+
format,
|
|
22
|
+
shouldAllowApi = true,
|
|
23
|
+
shouldAllowExample = true
|
|
22
24
|
} = {}) => {
|
|
23
25
|
const originalHeadingOpen = md.renderer.rules.heading_open;
|
|
24
26
|
const originalHtmlBlock = md.renderer.rules.html_block;
|
|
@@ -53,17 +55,19 @@ const headersPlugin = (md, {
|
|
|
53
55
|
return "";
|
|
54
56
|
}
|
|
55
57
|
env.toc = env.toc || [];
|
|
56
|
-
if (apiRE.test(token.content)) {
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
const title = `${
|
|
58
|
+
if (shouldAllowApi && apiRE.test(token.content)) {
|
|
59
|
+
const match = apiNameRE.exec(token.content);
|
|
60
|
+
if (match !== null) {
|
|
61
|
+
const title = `${match[1]} API`;
|
|
60
62
|
env.toc.push({ id: slugify$1(title), title, deep: true });
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
if (shouldAllowExample && exampleRE.test(token.content)) {
|
|
66
|
+
const match = token.content.match(exampleRE);
|
|
67
|
+
if (match !== null) {
|
|
68
|
+
const title = match[1] ?? "Example";
|
|
69
|
+
env.toc.push({ id: slugify$1("example-" + title), title, deep: true });
|
|
70
|
+
}
|
|
67
71
|
}
|
|
68
72
|
if (typeof originalHtmlBlock === "function") {
|
|
69
73
|
return originalHtmlBlock(tokens, idx, options, env, self);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@md-plugins/md-plugin-headers",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.28",
|
|
4
4
|
"description": "A markdown-it plugin for handling headers (H1-H6).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"markdown-it": "^14.1.0",
|
|
37
37
|
"@types/markdown-it": "^14.1.2",
|
|
38
|
-
"@md-plugins/shared": "0.1.0-alpha.
|
|
38
|
+
"@md-plugins/shared": "0.1.0-alpha.28"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"markdown-it": "^14.1.0"
|