@astrojs/mdx 0.19.0 → 0.19.1
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/.turbo/turbo-build.log +4 -5
- package/CHANGELOG.md +9 -0
- package/dist/remark-shiki.js +17 -0
- package/package.json +5 -5
- package/src/remark-shiki.ts +20 -0
- package/test/fixtures/mdx-images/package.json +2 -1
- package/test/fixtures/mdx-infinite-loop/package.json +1 -0
- package/test/fixtures/mdx-namespace/package.json +1 -0
- package/test/fixtures/mdx-page/package.json +1 -0
- package/test/fixtures/mdx-plus-react/package.json +1 -0
- package/test/fixtures/mdx-vite-env-vars/package.json +1 -0
- package/test/mdx-syntax-highlighting.test.js +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
[34m@astrojs/mdx:build: [0m
|
|
1
|
+
|
|
2
|
+
> @astrojs/mdx@0.19.1 build /home/runner/work/astro/astro/packages/integrations/mdx
|
|
3
|
+
> astro-scripts build "src/**/*.ts" && tsc
|
|
4
|
+
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @astrojs/mdx
|
|
2
2
|
|
|
3
|
+
## 0.19.1
|
|
4
|
+
|
|
5
|
+
### Patch 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
|
+
- Updated dependencies [[`49514e4ce`](https://github.com/withastro/astro/commit/49514e4ce40fedb39bf7decd2c296258efbdafc7)]:
|
|
10
|
+
- @astrojs/markdown-remark@2.2.0
|
|
11
|
+
|
|
3
12
|
## 0.19.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/dist/remark-shiki.js
CHANGED
|
@@ -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 }) => {
|
|
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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/mdx",
|
|
3
3
|
"description": "Add support for MDX pages in your Astro site",
|
|
4
|
-
"version": "0.19.
|
|
4
|
+
"version": "0.19.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"./package.json": "./package.json"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@astrojs/markdown-remark": "^2.
|
|
26
|
+
"@astrojs/markdown-remark": "^2.2.0",
|
|
27
27
|
"@astrojs/prism": "^2.1.1",
|
|
28
28
|
"@mdx-js/mdx": "^2.3.0",
|
|
29
29
|
"@mdx-js/rollup": "^2.3.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"remark-frontmatter": "^4.0.1",
|
|
38
38
|
"remark-gfm": "^3.0.1",
|
|
39
39
|
"remark-smartypants": "^2.0.0",
|
|
40
|
-
"shiki": "^0.
|
|
40
|
+
"shiki": "^0.14.1",
|
|
41
41
|
"source-map": "^0.7.4",
|
|
42
42
|
"unist-util-visit": "^4.1.0",
|
|
43
43
|
"vfile": "^5.3.2"
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"remark-rehype": "^10.1.0",
|
|
63
63
|
"remark-shiki-twoslash": "^3.1.0",
|
|
64
64
|
"remark-toc": "^8.0.1",
|
|
65
|
-
"vite": "^4.
|
|
66
|
-
"astro": "2.
|
|
65
|
+
"vite": "^4.3.1",
|
|
66
|
+
"astro": "2.4.0",
|
|
67
67
|
"astro-scripts": "0.0.14"
|
|
68
68
|
},
|
|
69
69
|
"engines": {
|
package/src/remark-shiki.ts
CHANGED
|
@@ -10,7 +10,27 @@ import { visit } from 'unist-util-visit';
|
|
|
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 ({ langs = [], theme = 'github-dark', wrap = false }: ShikiConfig) => {
|
|
33
|
+
theme = normalizeTheme(theme);
|
|
14
34
|
const cacheID: string = typeof theme === 'string' ? theme : theme.name;
|
|
15
35
|
let highlighterAsync = highlighterCacheAsync.get(cacheID);
|
|
16
36
|
if (!highlighterAsync) {
|
|
@@ -25,7 +25,7 @@ describe('MDX syntax highlighting', () => {
|
|
|
25
25
|
|
|
26
26
|
const shikiCodeBlock = document.querySelector('pre.astro-code');
|
|
27
27
|
expect(shikiCodeBlock).to.not.be.null;
|
|
28
|
-
expect(shikiCodeBlock.getAttribute('style')).to.contain('background-color:#
|
|
28
|
+
expect(shikiCodeBlock.getAttribute('style')).to.contain('background-color:#24292e');
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
it('respects markdown.shikiConfig.theme', async () => {
|