@astrojs/markdown-remark 4.1.0 → 4.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.
@@ -0,0 +1,2 @@
1
+ import type * as unified from 'unified';
2
+ export declare function importPlugin(p: string): Promise<unified.Plugin>;
@@ -0,0 +1,7 @@
1
+ async function importPlugin(p) {
2
+ const importResult = await import(p);
3
+ return importResult.default;
4
+ }
5
+ export {
6
+ importPlugin
7
+ };
@@ -0,0 +1,2 @@
1
+ import type * as unified from 'unified';
2
+ export declare function importPlugin(p: string): Promise<unified.Plugin>;
@@ -0,0 +1,18 @@
1
+ import { resolve as importMetaResolve } from "import-meta-resolve";
2
+ import path from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
+ let cwdUrlStr;
5
+ async function importPlugin(p) {
6
+ try {
7
+ const importResult2 = await import(p);
8
+ return importResult2.default;
9
+ } catch {
10
+ }
11
+ cwdUrlStr ??= pathToFileURL(path.join(process.cwd(), "package.json")).toString();
12
+ const resolved = importMetaResolve(p, cwdUrlStr);
13
+ const importResult = await import(resolved);
14
+ return importResult.default;
15
+ }
16
+ export {
17
+ importPlugin
18
+ };
@@ -1,19 +1,10 @@
1
- import { resolve as importMetaResolve } from "import-meta-resolve";
2
- import path from "node:path";
3
- import { pathToFileURL } from "node:url";
4
- const cwdUrlStr = pathToFileURL(path.join(process.cwd(), "package.json")).toString();
1
+ import { importPlugin as _importPlugin } from "#import-plugin";
5
2
  async function importPlugin(p) {
6
3
  if (typeof p === "string") {
7
- try {
8
- const importResult2 = await import(p);
9
- return importResult2.default;
10
- } catch {
11
- }
12
- const resolved = importMetaResolve(p, cwdUrlStr);
13
- const importResult = await import(resolved);
14
- return importResult.default;
4
+ return await _importPlugin(p);
5
+ } else {
6
+ return p;
15
7
  }
16
- return p;
17
8
  }
18
9
  function loadPlugins(items) {
19
10
  return items.map((p) => {
package/dist/shiki.js CHANGED
@@ -41,8 +41,8 @@ async function createShikiHighlighter({
41
41
  if (inline) {
42
42
  node.tagName = "code";
43
43
  }
44
- const classValue = node.properties.class ?? "";
45
- const styleValue = node.properties.style ?? "";
44
+ const classValue = normalizePropAsString(node.properties.class) ?? "";
45
+ const styleValue = normalizePropAsString(node.properties.style) ?? "";
46
46
  node.properties.class = classValue.replace(/shiki/g, "astro-code");
47
47
  if (wrap === false) {
48
48
  node.properties.style = styleValue + "; overflow-x: auto;";
@@ -93,6 +93,9 @@ async function createShikiHighlighter({
93
93
  }
94
94
  };
95
95
  }
96
+ function normalizePropAsString(value) {
97
+ return Array.isArray(value) ? value.join(" ") : value;
98
+ }
96
99
  function replaceCssVariables(str) {
97
100
  return str.replace(COLOR_REPLACEMENT_REGEX, (match) => ASTRO_COLOR_REPLACEMENTS[match] || match);
98
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/markdown-remark",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -16,6 +16,12 @@
16
16
  ".": "./dist/index.js",
17
17
  "./dist/internal.js": "./dist/internal.js"
18
18
  },
19
+ "imports": {
20
+ "#import-plugin": {
21
+ "browser": "./dist/import-plugin-browser.js",
22
+ "default": "./dist/import-plugin-default.js"
23
+ }
24
+ },
19
25
  "files": [
20
26
  "dist"
21
27
  ],
@@ -43,6 +49,7 @@
43
49
  "@types/mocha": "^10.0.4",
44
50
  "@types/unist": "^3.0.2",
45
51
  "chai": "^4.3.7",
52
+ "esbuild": "^0.19.6",
46
53
  "mdast-util-mdx-expression": "^2.0.0",
47
54
  "mocha": "^10.2.0",
48
55
  "astro-scripts": "0.0.14"