@astrojs/markdown-remark 7.0.0-beta.1 → 7.0.0-beta.2

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.
Files changed (2) hide show
  1. package/dist/shiki.js +11 -2
  2. package/package.json +3 -3
package/dist/shiki.js CHANGED
@@ -7,6 +7,7 @@ let _cssVariablesTheme;
7
7
  const cssVariablesTheme = () => _cssVariablesTheme ?? (_cssVariablesTheme = createCssVariablesTheme({
8
8
  variablePrefix: "--astro-code-"
9
9
  }));
10
+ const cachedHighlighters = /* @__PURE__ */ new Map();
10
11
  async function createShikiHighlighter({
11
12
  langs = [],
12
13
  theme = "github-dark",
@@ -14,11 +15,19 @@ async function createShikiHighlighter({
14
15
  langAlias = {}
15
16
  } = {}) {
16
17
  theme = theme === "css-variables" ? cssVariablesTheme() : theme;
17
- const highlighter = await createHighlighter({
18
+ const highlighterOptions = {
18
19
  langs: ["plaintext", ...langs],
19
20
  langAlias,
20
21
  themes: Object.values(themes).length ? Object.values(themes) : [theme]
21
- });
22
+ };
23
+ const key = JSON.stringify(highlighterOptions, Object.keys(highlighterOptions).sort());
24
+ let highlighter;
25
+ if (cachedHighlighters.has(key)) {
26
+ highlighter = cachedHighlighters.get(key);
27
+ } else {
28
+ highlighter = await createHighlighter(highlighterOptions);
29
+ cachedHighlighters.set(key, highlighter);
30
+ }
22
31
  async function highlight(code, lang = "plaintext", options, to) {
23
32
  const resolvedLang = langAlias[lang] ?? lang;
24
33
  const loadedLanguages = highlighter.getLoadedLanguages();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/markdown-remark",
3
- "version": "7.0.0-beta.1",
3
+ "version": "7.0.0-beta.2",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "remark-parse": "^11.0.0",
37
37
  "remark-rehype": "^11.1.2",
38
38
  "remark-smartypants": "^3.0.2",
39
- "shiki": "^3.20.0",
39
+ "shiki": "^3.21.0",
40
40
  "smol-toml": "^1.6.0",
41
41
  "unified": "^11.0.5",
42
42
  "unist-util-remove-position": "^5.0.0",
@@ -44,7 +44,7 @@
44
44
  "unist-util-visit-parents": "^6.0.2",
45
45
  "vfile": "^6.0.3",
46
46
  "@astrojs/internal-helpers": "0.7.5",
47
- "@astrojs/prism": "4.0.0-beta.1"
47
+ "@astrojs/prism": "4.0.0-beta.2"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/estree": "^1.0.8",