@md-plugins/md-plugin-headers 0.1.0-alpha.2 → 0.1.0-alpha.20

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 CHANGED
@@ -148,6 +148,10 @@ md.use(headersPlugin, {
148
148
  pnpm test
149
149
  ```
150
150
 
151
+ ## Documentation
152
+
153
+ In case this README falls out of date, please refer to the [documentation](https://md-plugins.netlify.app/md-plugins/headers/overview) for the latest information.
154
+
151
155
  ## License
152
156
 
153
157
  This project is licensed under the MIT License. See the [LICENSE](LICENSE.md) file for details.
package/dist/index.mjs CHANGED
@@ -1,9 +1,12 @@
1
- import { slugify } from '@md-plugins/shared';
1
+ const rControl = /[\u0000-\u001f]/g;
2
+ const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'“”‘’<>,.?/]+/g;
3
+ const rCombining = /[\u0300-\u036F]/g;
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");
2
6
 
3
7
  const titleRE = /<\/?[^>]+(>|$)/g;
4
8
  const apiRE = /^<MarkdownApi /;
5
9
  const apiNameRE = /(?:file|name)="([^"]+)"/;
6
- const installationRE = /^<MarkdownInstallation(?:\s+title="([^"]*)")?\s*/;
7
10
  const exampleRE = /^<MarkdownExample(?:\s+title="([^"]*)")?\s*/;
8
11
  function parseContent(str, slugify$1 = slugify, format = (_str) => _str) {
9
12
  const title = String(str).replace(titleRE, "").trim();
@@ -57,15 +60,10 @@ const headersPlugin = (md, {
57
60
  env.toc.push({ id: slugify$1(title), title, deep: true });
58
61
  }
59
62
  }
60
- let match = token.content.match(installationRE);
61
- if (match !== null) {
62
- const title = match[1] ?? "Installation";
63
- env.toc.push({ id: slugify$1(title), title, deep: true });
64
- }
65
- match = token.content.match(exampleRE);
63
+ const match = token.content.match(exampleRE);
66
64
  if (match !== null) {
67
65
  const title = match[1] ?? "Example";
68
- env.toc.push({ id: slugify$1(title), title, deep: true });
66
+ env.toc.push({ id: "example--" + slugify$1(title), title, deep: true });
69
67
  }
70
68
  if (typeof originalHtmlBlock === "function") {
71
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.2",
3
+ "version": "0.1.0-alpha.20",
4
4
  "description": "A markdown-it plugin for handling headers (H1-H6).",
5
5
  "keywords": [
6
6
  "markdown-it",
@@ -32,10 +32,13 @@
32
32
  "files": [
33
33
  "./dist"
34
34
  ],
35
- "dependencies": {
36
- "@types/markdown-it": "^14.1.2",
35
+ "devDependencies": {
37
36
  "markdown-it": "^14.1.0",
38
- "@md-plugins/shared": "0.1.0-alpha.2"
37
+ "@types/markdown-it": "^14.1.2",
38
+ "@md-plugins/shared": "0.1.0-alpha.20"
39
+ },
40
+ "peerDependencies": {
41
+ "markdown-it": "^14.1.0"
39
42
  },
40
43
  "publishConfig": {
41
44
  "access": "public"