@md-plugins/md-plugin-headers 0.1.0-alpha.20 → 0.1.0-alpha.22
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.mjs +4 -4
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
const andRE = /&/g;
|
|
2
|
+
const rCombining = /[\u0300-\u036F]/g;
|
|
1
3
|
const rControl = /[\u0000-\u001f]/g;
|
|
2
4
|
const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'“”‘’<>,.?/]+/g;
|
|
3
|
-
const
|
|
4
|
-
const andRE = /&/g;
|
|
5
|
-
const slugify = (str) => str.normalize("NFKD").toLowerCase().replace(andRE, "-and-").replace(rCombining, "").replace(rControl, "-").replace(rSpecial, "-").replace(/[^a-z0-9-]+/g, "").replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "").replace(/^(\d)/, "_$1");
|
|
5
|
+
const slugify = (str) => str.normalize("NFKD").replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase().replace(andRE, "-and-").replace(rCombining, "").replace(rControl, "-").replace(rSpecial, "-").replace(/[^a-z0-9-]+/g, "").replace(/-{2,}/g, "-").replace(/(^-|-$)/g, "").replace(/^(\d)/, "_$1");
|
|
6
6
|
|
|
7
7
|
const titleRE = /<\/?[^>]+(>|$)/g;
|
|
8
8
|
const apiRE = /^<MarkdownApi /;
|
|
@@ -63,7 +63,7 @@ const headersPlugin = (md, {
|
|
|
63
63
|
const match = token.content.match(exampleRE);
|
|
64
64
|
if (match !== null) {
|
|
65
65
|
const title = match[1] ?? "Example";
|
|
66
|
-
env.toc.push({ id: "example
|
|
66
|
+
env.toc.push({ id: slugify$1("example-" + title), title, deep: true });
|
|
67
67
|
}
|
|
68
68
|
if (typeof originalHtmlBlock === "function") {
|
|
69
69
|
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.22",
|
|
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.22"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"markdown-it": "^14.1.0"
|