@astrojs/markdown-remark 2.1.4 → 2.2.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.
@@ -1,5 +1,4 @@
1
- @astrojs/markdown-remark:build: cache hit, replaying output 8b8e166000163d0b
2
- @astrojs/markdown-remark:build: 
3
- @astrojs/markdown-remark:build: > @astrojs/markdown-remark@2.1.4 build /home/runner/work/astro/astro/packages/markdown/remark
4
- @astrojs/markdown-remark:build: > astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json
5
- @astrojs/markdown-remark:build: 
1
+
2
+ > @astrojs/markdown-remark@2.2.0 build /home/runner/work/astro/astro/packages/markdown/remark
3
+ > astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json
4
+
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @astrojs/markdown-remark
2
2
 
3
+ ## 2.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#6932](https://github.com/withastro/astro/pull/6932) [`49514e4ce`](https://github.com/withastro/astro/commit/49514e4ce40fedb39bf7decd2c296258efbdafc7) Thanks [@bluwy](https://github.com/bluwy)! - Upgrade shiki to v0.14.1. This updates the shiki theme colors and adds the theme name to the `pre` tag, e.g. `<pre class="astro-code github-dark">`.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`818252acd`](https://github.com/withastro/astro/commit/818252acda3c00499cea51ffa0f26d4c2ccd3a02), [`80e3d4d3d`](https://github.com/withastro/astro/commit/80e3d4d3d0f7719d8eae5435bba3805503057511), [`3326492b9`](https://github.com/withastro/astro/commit/3326492b94f76ed2b0154dd9b9a1a9eb883c1e31), [`cac4a321e`](https://github.com/withastro/astro/commit/cac4a321e814fb805eb0e3ced469e25261a50885), [`831b67cdb`](https://github.com/withastro/astro/commit/831b67cdb8250f93f66e3b171fab024652bf80f2), [`49514e4ce`](https://github.com/withastro/astro/commit/49514e4ce40fedb39bf7decd2c296258efbdafc7), [`0883fd487`](https://github.com/withastro/astro/commit/0883fd4875548a613df122f0b87a1ca8b7a7cf7d)]:
12
+ - astro@2.4.0
13
+
3
14
  ## 2.1.4
4
15
 
5
16
  ### Patch Changes
@@ -1,7 +1,24 @@
1
1
  import { getHighlighter } from "shiki";
2
2
  import { visit } from "unist-util-visit";
3
3
  const highlighterCacheAsync = /* @__PURE__ */ new Map();
4
+ const compatThemes = {
5
+ "material-darker": "material-theme-darker",
6
+ "material-default": "material-theme",
7
+ "material-lighter": "material-theme-lighter",
8
+ "material-ocean": "material-theme-ocean",
9
+ "material-palenight": "material-theme-palenight"
10
+ };
11
+ const normalizeTheme = (theme) => {
12
+ if (typeof theme === "string") {
13
+ return compatThemes[theme] || theme;
14
+ } else if (compatThemes[theme.name]) {
15
+ return { ...theme, name: compatThemes[theme.name] };
16
+ } else {
17
+ return theme;
18
+ }
19
+ };
4
20
  const remarkShiki = async ({ langs = [], theme = "github-dark", wrap = false }, scopedClassName) => {
21
+ theme = normalizeTheme(theme);
5
22
  const cacheID = typeof theme === "string" ? theme : theme.name;
6
23
  let highlighterAsync = highlighterCacheAsync.get(cacheID);
7
24
  if (!highlighterAsync) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/markdown-remark",
3
- "version": "2.1.4",
3
+ "version": "2.2.0",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -17,7 +17,7 @@
17
17
  "./dist/internal.js": "./dist/internal.js"
18
18
  },
19
19
  "peerDependencies": {
20
- "astro": "^2.3.0"
20
+ "astro": "^2.4.0"
21
21
  },
22
22
  "dependencies": {
23
23
  "@astrojs/prism": "^2.1.0",
@@ -29,7 +29,7 @@
29
29
  "remark-parse": "^10.0.1",
30
30
  "remark-rehype": "^10.1.0",
31
31
  "remark-smartypants": "^2.0.0",
32
- "shiki": "^0.11.1",
32
+ "shiki": "^0.14.1",
33
33
  "unified": "^10.1.2",
34
34
  "unist-util-visit": "^4.1.0",
35
35
  "vfile": "^5.3.2"
@@ -10,10 +10,30 @@ import type { ShikiConfig } from './types.js';
10
10
  */
11
11
  const highlighterCacheAsync = new Map<string, Promise<shiki.Highlighter>>();
12
12
 
13
+ // Map of old theme names to new names to preserve compatibility when we upgrade shiki
14
+ const compatThemes: Record<string, string> = {
15
+ 'material-darker': 'material-theme-darker',
16
+ 'material-default': 'material-theme',
17
+ 'material-lighter': 'material-theme-lighter',
18
+ 'material-ocean': 'material-theme-ocean',
19
+ 'material-palenight': 'material-theme-palenight',
20
+ };
21
+
22
+ const normalizeTheme = (theme: string | shiki.IShikiTheme) => {
23
+ if (typeof theme === 'string') {
24
+ return compatThemes[theme] || theme;
25
+ } else if (compatThemes[theme.name]) {
26
+ return { ...theme, name: compatThemes[theme.name] };
27
+ } else {
28
+ return theme;
29
+ }
30
+ };
31
+
13
32
  const remarkShiki = async (
14
33
  { langs = [], theme = 'github-dark', wrap = false }: ShikiConfig,
15
34
  scopedClassName?: string | null
16
35
  ) => {
36
+ theme = normalizeTheme(theme);
17
37
  const cacheID: string = typeof theme === 'string' ? theme : theme.name;
18
38
  let highlighterAsync = highlighterCacheAsync.get(cacheID);
19
39
  if (!highlighterAsync) {