@astrojs/markdown-remark 0.11.3 → 0.11.4
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 -0
- package/CHANGELOG.md +7 -0
- package/dist/index.js +4 -4
- package/dist/rehype-collect-headers.js +1 -1
- package/dist/rehype-expressions.js +1 -20
- package/dist/rehype-islands.js +3 -21
- package/dist/remark-prism.js +3 -3
- package/package.json +4 -4
- package/src/index.ts +5 -4
- package/src/rehype-collect-headers.ts +1 -1
- package/src/remark-prism.ts +4 -3
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
[36m@astrojs/markdown-remark:build: [0mcache hit, replaying output [2m11f745aa911f62c3[0m
|
|
2
|
+
[36m@astrojs/markdown-remark:build: [0m
|
|
3
|
+
[36m@astrojs/markdown-remark:build: [0m> @astrojs/markdown-remark@0.11.4 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
package/dist/index.js
CHANGED
|
@@ -41,8 +41,8 @@ async function renderMarkdown(content, opts = {}) {
|
|
|
41
41
|
}
|
|
42
42
|
const loadedRemarkPlugins = await Promise.all(loadPlugins(remarkPlugins));
|
|
43
43
|
const loadedRehypePlugins = await Promise.all(loadPlugins(rehypePlugins));
|
|
44
|
-
loadedRemarkPlugins.forEach(([plugin,
|
|
45
|
-
parser.use([[plugin,
|
|
44
|
+
loadedRemarkPlugins.forEach(([plugin, pluginOpts]) => {
|
|
45
|
+
parser.use([[plugin, pluginOpts]]);
|
|
46
46
|
});
|
|
47
47
|
if (scopedClassName) {
|
|
48
48
|
parser.use([scopedStyles(scopedClassName)]);
|
|
@@ -67,8 +67,8 @@ async function renderMarkdown(content, opts = {}) {
|
|
|
67
67
|
}
|
|
68
68
|
]
|
|
69
69
|
]);
|
|
70
|
-
loadedRehypePlugins.forEach(([plugin,
|
|
71
|
-
parser.use([[plugin,
|
|
70
|
+
loadedRehypePlugins.forEach(([plugin, pluginOpts]) => {
|
|
71
|
+
parser.use([[plugin, pluginOpts]]);
|
|
72
72
|
});
|
|
73
73
|
parser.use(isMDX ? [rehypeJsx, rehypeExpressions] : [rehypeRaw]).use(rehypeEscape).use(rehypeIslands).use([rehypeCollectHeaders]).use(rehypeStringify, { allowDangerousHtml: true });
|
|
74
74
|
let result;
|
|
@@ -18,7 +18,7 @@ function createCollectHeaders() {
|
|
|
18
18
|
const depth = Number.parseInt(level);
|
|
19
19
|
let text = "";
|
|
20
20
|
let isJSX = false;
|
|
21
|
-
visit(node, (child,
|
|
21
|
+
visit(node, (child, __, parent) => {
|
|
22
22
|
if (child.type === "element" || parent == null) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
@@ -1,28 +1,9 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
import { map } from "unist-util-map";
|
|
21
2
|
function rehypeExpressions() {
|
|
22
3
|
return function(node) {
|
|
23
4
|
return map(node, (child) => {
|
|
24
5
|
if (child.type === "text") {
|
|
25
|
-
return
|
|
6
|
+
return { ...child, type: "raw" };
|
|
26
7
|
}
|
|
27
8
|
if (child.type === "mdxTextExpression") {
|
|
28
9
|
return { type: "raw", value: `{${child.value}}` };
|
package/dist/rehype-islands.js
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
1
|
import { SKIP, visit as _visit } from "unist-util-visit";
|
|
21
2
|
const visit = _visit;
|
|
22
3
|
function rehypeIslands() {
|
|
@@ -26,10 +7,11 @@ function rehypeIslands() {
|
|
|
26
7
|
visit(el, "text", (child, index, parent) => {
|
|
27
8
|
if (child.type === "text") {
|
|
28
9
|
if (parent && child.value.indexOf("<!--") > -1 && index != null) {
|
|
29
|
-
parent.children.splice(index, 1,
|
|
10
|
+
parent.children.splice(index, 1, {
|
|
11
|
+
...child,
|
|
30
12
|
type: "comment",
|
|
31
13
|
value: child.value.replace("<!--", "").replace("-->", "").trim()
|
|
32
|
-
})
|
|
14
|
+
});
|
|
33
15
|
return [SKIP, index];
|
|
34
16
|
}
|
|
35
17
|
child.value = child.value.replace(/\n+/g, "");
|
package/dist/remark-prism.js
CHANGED
|
@@ -9,9 +9,9 @@ function runHighlighter(lang, code) {
|
|
|
9
9
|
if (lang == null) {
|
|
10
10
|
lang = "plaintext";
|
|
11
11
|
}
|
|
12
|
-
const ensureLoaded = (
|
|
13
|
-
if (
|
|
14
|
-
loadLanguages([
|
|
12
|
+
const ensureLoaded = (language) => {
|
|
13
|
+
if (language && !Prism.languages[language]) {
|
|
14
|
+
loadLanguages([language]);
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
if (languageMap.has(lang)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/markdown-remark",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "withastro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@astrojs/micromark-extension-mdx-jsx": "^1.0.3",
|
|
21
|
-
"@astrojs/prism": "^0.
|
|
21
|
+
"@astrojs/prism": "^0.5.0",
|
|
22
22
|
"acorn": "^8.7.1",
|
|
23
23
|
"acorn-jsx": "^5.3.2",
|
|
24
24
|
"assert": "^2.0.0",
|
|
25
25
|
"github-slugger": "^1.4.0",
|
|
26
|
-
"mdast-util-mdx-expression": "^1.2.
|
|
26
|
+
"mdast-util-mdx-expression": "^1.2.1",
|
|
27
27
|
"mdast-util-mdx-jsx": "^1.2.0",
|
|
28
28
|
"mdast-util-to-string": "^3.1.0",
|
|
29
29
|
"micromark-extension-mdx-expression": "^1.0.3",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@types/mocha": "^9.1.1",
|
|
51
51
|
"@types/prismjs": "^1.26.0",
|
|
52
52
|
"@types/unist": "^2.0.6",
|
|
53
|
-
"astro-scripts": "0.0.
|
|
53
|
+
"astro-scripts": "0.0.6",
|
|
54
54
|
"chai": "^4.3.6",
|
|
55
55
|
"micromark-util-types": "^1.0.2",
|
|
56
56
|
"mocha": "^9.2.2"
|
package/src/index.ts
CHANGED
|
@@ -57,8 +57,8 @@ export async function renderMarkdown(
|
|
|
57
57
|
const loadedRemarkPlugins = await Promise.all(loadPlugins(remarkPlugins));
|
|
58
58
|
const loadedRehypePlugins = await Promise.all(loadPlugins(rehypePlugins));
|
|
59
59
|
|
|
60
|
-
loadedRemarkPlugins.forEach(([plugin,
|
|
61
|
-
parser.use([[plugin,
|
|
60
|
+
loadedRemarkPlugins.forEach(([plugin, pluginOpts]) => {
|
|
61
|
+
parser.use([[plugin, pluginOpts]]);
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
if (scopedClassName) {
|
|
@@ -87,8 +87,8 @@ export async function renderMarkdown(
|
|
|
87
87
|
],
|
|
88
88
|
]);
|
|
89
89
|
|
|
90
|
-
loadedRehypePlugins.forEach(([plugin,
|
|
91
|
-
parser.use([[plugin,
|
|
90
|
+
loadedRehypePlugins.forEach(([plugin, pluginOpts]) => {
|
|
91
|
+
parser.use([[plugin, pluginOpts]]);
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
parser
|
|
@@ -106,6 +106,7 @@ export async function renderMarkdown(
|
|
|
106
106
|
// Ensure that the error message contains the input filename
|
|
107
107
|
// to make it easier for the user to fix the issue
|
|
108
108
|
err = prefixError(err, `Failed to parse Markdown file "${input.path}"`);
|
|
109
|
+
// eslint-disable-next-line no-console
|
|
109
110
|
console.error(err);
|
|
110
111
|
throw err;
|
|
111
112
|
}
|
package/src/remark-prism.ts
CHANGED
|
@@ -13,9 +13,9 @@ function runHighlighter(lang: string, code: string) {
|
|
|
13
13
|
lang = 'plaintext';
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const ensureLoaded = (
|
|
17
|
-
if (
|
|
18
|
-
loadLanguages([
|
|
16
|
+
const ensureLoaded = (language: string) => {
|
|
17
|
+
if (language && !Prism.languages[language]) {
|
|
18
|
+
loadLanguages([language]);
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
|
|
@@ -30,6 +30,7 @@ function runHighlighter(lang: string, code: string) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
if (lang && !Prism.languages[lang]) {
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
33
34
|
console.warn(`Unable to load the language: ${lang}`);
|
|
34
35
|
}
|
|
35
36
|
|