@astrojs/markdown-remark 3.3.0 → 3.4.0

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.js CHANGED
@@ -28,6 +28,7 @@ const markdownConfigDefaults = {
28
28
  shikiConfig: {
29
29
  langs: [],
30
30
  theme: "github-dark",
31
+ experimentalThemes: {},
31
32
  wrap: false
32
33
  },
33
34
  remarkPlugins: [],
@@ -1,2 +1,2 @@
1
1
  import type { RemarkPlugin, ShikiConfig } from './types.js';
2
- export declare function remarkShiki({ langs, theme, wrap, }?: ShikiConfig): ReturnType<RemarkPlugin>;
2
+ export declare function remarkShiki({ langs, theme, experimentalThemes, wrap, }?: ShikiConfig): ReturnType<RemarkPlugin>;
@@ -21,14 +21,16 @@ const highlighterCacheAsync = /* @__PURE__ */ new Map();
21
21
  function remarkShiki({
22
22
  langs = [],
23
23
  theme = "github-dark",
24
+ experimentalThemes = {},
24
25
  wrap = false
25
26
  } = {}) {
26
- const cacheId = (typeof theme === "string" ? theme : theme.name ?? "") + langs.map((l) => l.name ?? l.id).join(",");
27
+ const themes = experimentalThemes;
28
+ const cacheId = Object.values(themes).map((t) => typeof t === "string" ? t : t.name ?? "").join(",") + (typeof theme === "string" ? theme : theme.name ?? "") + langs.map((l) => l.name ?? l.id).join(",");
27
29
  let highlighterAsync = highlighterCacheAsync.get(cacheId);
28
30
  if (!highlighterAsync) {
29
31
  highlighterAsync = getHighlighter({
30
32
  langs: langs.length ? langs : Object.keys(bundledLanguages),
31
- themes: [theme]
33
+ themes: Object.values(themes).length ? Object.values(themes) : [theme]
32
34
  });
33
35
  highlighterCacheAsync.set(cacheId, highlighterAsync);
34
36
  }
@@ -47,7 +49,8 @@ function remarkShiki({
47
49
  } else {
48
50
  lang = "plaintext";
49
51
  }
50
- let html = highlighter.codeToHtml(node.value, { lang, theme });
52
+ let themeOptions = Object.values(themes).length ? { themes } : { theme };
53
+ let html = highlighter.codeToHtml(node.value, { ...themeOptions, lang });
51
54
  html = html.replace(/<pre class="(.*?)shiki(.*?)"/, `<pre class="$1astro-code$2"`);
52
55
  if (node.lang === "diff") {
53
56
  html = html.replace(
package/dist/types.d.ts CHANGED
@@ -19,6 +19,7 @@ export type RemarkRehype = Omit<RemarkRehypeOptions, 'handlers' | 'unknownHandle
19
19
  export interface ShikiConfig {
20
20
  langs?: LanguageRegistration[];
21
21
  theme?: BuiltinTheme | ThemeRegistration | ThemeRegistrationRaw;
22
+ experimentalThemes?: Record<string, BuiltinTheme | ThemeRegistration | ThemeRegistrationRaw>;
22
23
  wrap?: boolean | null;
23
24
  }
24
25
  export interface AstroMarkdownOptions {
@@ -41,8 +42,6 @@ export interface MarkdownProcessor {
41
42
  render: (content: string, opts?: MarkdownProcessorRenderOptions) => Promise<MarkdownProcessorRenderResult>;
42
43
  }
43
44
  export interface MarkdownProcessorRenderOptions {
44
- /** @internal */
45
- fileURL?: URL;
46
45
  /** Used for frontmatter injection plugins */
47
46
  frontmatter?: Record<string, any>;
48
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/markdown-remark",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -20,7 +20,7 @@
20
20
  "dist"
21
21
  ],
22
22
  "peerDependencies": {
23
- "astro": "^3.3.0"
23
+ "astro": "^3.0.0"
24
24
  },
25
25
  "dependencies": {
26
26
  "@astrojs/prism": "^3.0.0",