@observablehq/notebook-kit 2.5.3 → 2.5.4

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/observablehq/notebook-kit.git"
7
7
  },
8
- "version": "2.5.3",
8
+ "version": "2.5.4",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "test": "TZ=America/Los_Angeles vitest",
@@ -1,10 +1,11 @@
1
- import slugify from "@sindresorhus/slugify";
1
+ import { slugifyWithCounter } from "@sindresorhus/slugify";
2
2
  import MarkdownIt from "markdown-it";
3
3
  import MarkdownItAnchor from "markdown-it-anchor";
4
4
  const mi = MarkdownIt({ html: true, linkify: true, typographer: true });
5
+ const slugify = slugifyWithCounter();
5
6
  mi.use(MarkdownItAnchor, {
6
7
  level: [2, 3],
7
- slugify: (s) => slugify(s),
8
+ slugify: (s) => slugify(s).replace(/^(?=\d)/, "-"),
8
9
  permalink: MarkdownItAnchor.permalink.headerLink({ class: "" })
9
10
  });
10
11
  export function MarkdownRenderer({ document = window.document } = {}) {
@@ -42,6 +43,7 @@ export function MarkdownRenderer({ document = window.document } = {}) {
42
43
  source += template[i + 1];
43
44
  }
44
45
  // Render the text.
46
+ slugify.reset();
45
47
  const root = document.createElement("div");
46
48
  root.innerHTML = mi.render(source);
47
49
  // Walk the rendered content to replace anchor placeholders.
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/observablehq/notebook-kit.git"
7
7
  },
8
- "version": "2.5.3",
8
+ "version": "2.5.4",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "test": "TZ=America/Los_Angeles vitest",