@astrojs/markdown-remark 0.11.5 → 0.11.6
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 +5 -5
- package/CHANGELOG.md +9 -0
- package/dist/remark-shiki.js +13 -1
- package/package.json +2 -2
- package/src/remark-shiki.ts +15 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
[
|
|
2
|
-
[
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
[
|
|
1
|
+
[36m@astrojs/markdown-remark:build: [0mcache hit, replaying output [2m29cccc2060a2f573[0m
|
|
2
|
+
[36m@astrojs/markdown-remark:build: [0m
|
|
3
|
+
[36m@astrojs/markdown-remark:build: [0m> @astrojs/markdown-remark@0.11.6 build /home/runner/work/astro/astro/packages/markdown/remark
|
|
4
|
+
[36m@astrojs/markdown-remark:build: [0m> astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json
|
|
5
|
+
[36m@astrojs/markdown-remark:build: [0m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @astrojs/markdown-remark
|
|
2
2
|
|
|
3
|
+
## 0.11.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#3911](https://github.com/withastro/astro/pull/3911) [`ca45c0c27`](https://github.com/withastro/astro/commit/ca45c0c270f5ca3f7d2fb113a235d415cecdb333) Thanks [@JuanM04](https://github.com/JuanM04)! - Don't throw when Shiki doesn't recognize a language
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`b48767985`](https://github.com/withastro/astro/commit/b48767985359bd359df8071324952ea5f2bc0d86)]:
|
|
10
|
+
- @astrojs/prism@0.6.0
|
|
11
|
+
|
|
3
12
|
## 0.11.5
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/remark-shiki.js
CHANGED
|
@@ -14,7 +14,19 @@ const remarkShiki = async ({ langs = [], theme = "github-dark", wrap = false },
|
|
|
14
14
|
}
|
|
15
15
|
return () => (tree) => {
|
|
16
16
|
visit(tree, "code", (node) => {
|
|
17
|
-
let
|
|
17
|
+
let lang;
|
|
18
|
+
if (typeof node.lang === "string") {
|
|
19
|
+
const langExists = highlighter.getLoadedLanguages().includes(node.lang);
|
|
20
|
+
if (langExists) {
|
|
21
|
+
lang = node.lang;
|
|
22
|
+
} else {
|
|
23
|
+
console.warn(`The language "${node.lang}" doesn't exist, falling back to plaintext.`);
|
|
24
|
+
lang = "plaintext";
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
lang = "plaintext";
|
|
28
|
+
}
|
|
29
|
+
let html = highlighter.codeToHtml(node.value, { lang });
|
|
18
30
|
html = html.replace('<pre class="shiki"', `<pre is:raw class="astro-code${scopedClassName ? " " + scopedClassName : ""}"`);
|
|
19
31
|
html = html.replace(/style="(background-)?color: var\(--shiki-/g, 'style="$1color: var(--astro-code-');
|
|
20
32
|
if (node.lang === "diff") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/markdown-remark",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "withastro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@astrojs/micromark-extension-mdx-jsx": "^1.0.3",
|
|
20
|
-
"@astrojs/prism": "^0.
|
|
20
|
+
"@astrojs/prism": "^0.6.0",
|
|
21
21
|
"acorn": "^8.7.1",
|
|
22
22
|
"acorn-jsx": "^5.3.2",
|
|
23
23
|
"assert": "^2.0.0",
|
package/src/remark-shiki.ts
CHANGED
|
@@ -30,7 +30,21 @@ const remarkShiki = async (
|
|
|
30
30
|
|
|
31
31
|
return () => (tree: any) => {
|
|
32
32
|
visit(tree, 'code', (node) => {
|
|
33
|
-
let
|
|
33
|
+
let lang: string;
|
|
34
|
+
|
|
35
|
+
if (typeof node.lang === 'string') {
|
|
36
|
+
const langExists = highlighter.getLoadedLanguages().includes(node.lang);
|
|
37
|
+
if (langExists) {
|
|
38
|
+
lang = node.lang;
|
|
39
|
+
} else {
|
|
40
|
+
console.warn(`The language "${node.lang}" doesn't exist, falling back to plaintext.`);
|
|
41
|
+
lang = 'plaintext';
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
lang = 'plaintext';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let html = highlighter!.codeToHtml(node.value, { lang });
|
|
34
48
|
|
|
35
49
|
// Q: Couldn't these regexes match on a user's inputted code blocks?
|
|
36
50
|
// A: Nope! All rendered HTML is properly escaped.
|