@astrojs/markdown-remark 6.3.7 → 7.0.0-alpha.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,7 +1,8 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import { pathToFileURL } from "node:url";
|
|
3
|
-
import { resolve as importMetaResolve } from "import-meta-resolve";
|
|
4
4
|
let cwdUrlStr;
|
|
5
|
+
const require2 = createRequire(import.meta.url);
|
|
5
6
|
async function importPlugin(p) {
|
|
6
7
|
try {
|
|
7
8
|
const importResult2 = await import(
|
|
@@ -12,7 +13,7 @@ async function importPlugin(p) {
|
|
|
12
13
|
} catch {
|
|
13
14
|
}
|
|
14
15
|
cwdUrlStr ??= pathToFileURL(path.join(process.cwd(), "package.json")).toString();
|
|
15
|
-
const resolved =
|
|
16
|
+
const resolved = pathToFileURL(require2.resolve(p, { paths: [cwdUrlStr] })).toString();
|
|
16
17
|
const importResult = await import(
|
|
17
18
|
/* @vite-ignore */
|
|
18
19
|
resolved
|
package/dist/index.js
CHANGED
|
@@ -55,8 +55,7 @@ async function createMarkdownProcessor(opts) {
|
|
|
55
55
|
rehypePlugins = markdownConfigDefaults.rehypePlugins,
|
|
56
56
|
remarkRehype: remarkRehypeOptions = markdownConfigDefaults.remarkRehype,
|
|
57
57
|
gfm = markdownConfigDefaults.gfm,
|
|
58
|
-
smartypants = markdownConfigDefaults.smartypants
|
|
59
|
-
experimentalHeadingIdCompat = false
|
|
58
|
+
smartypants = markdownConfigDefaults.smartypants
|
|
60
59
|
} = opts ?? {};
|
|
61
60
|
const loadedRemarkPlugins = await Promise.all(loadPlugins(remarkPlugins));
|
|
62
61
|
const loadedRehypePlugins = await Promise.all(loadPlugins(rehypePlugins));
|
|
@@ -94,7 +93,7 @@ async function createMarkdownProcessor(opts) {
|
|
|
94
93
|
}
|
|
95
94
|
parser.use(rehypeImages);
|
|
96
95
|
if (!isPerformanceBenchmark) {
|
|
97
|
-
parser.use(rehypeHeadingIds
|
|
96
|
+
parser.use(rehypeHeadingIds);
|
|
98
97
|
}
|
|
99
98
|
parser.use(rehypeRaw).use(rehypeStringify, { allowDangerousHtml: true });
|
|
100
99
|
return {
|
|
@@ -2,10 +2,6 @@ import type { RehypePlugin } from './types.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Rehype plugin that adds `id` attributes to headings based on their text content.
|
|
4
4
|
*
|
|
5
|
-
* @param options Optional configuration object for the plugin.
|
|
6
|
-
*
|
|
7
5
|
* @see https://docs.astro.build/en/guides/markdown-content/#heading-ids-and-plugins
|
|
8
6
|
*/
|
|
9
|
-
export declare function rehypeHeadingIds(
|
|
10
|
-
experimentalHeadingIdCompat?: boolean;
|
|
11
|
-
}): ReturnType<RehypePlugin>;
|
|
7
|
+
export declare function rehypeHeadingIds(): ReturnType<RehypePlugin>;
|
|
@@ -2,9 +2,7 @@ import Slugger from "github-slugger";
|
|
|
2
2
|
import { visit } from "unist-util-visit";
|
|
3
3
|
const rawNodeTypes = /* @__PURE__ */ new Set(["text", "raw", "mdxTextExpression"]);
|
|
4
4
|
const codeTagNames = /* @__PURE__ */ new Set(["code", "pre"]);
|
|
5
|
-
function rehypeHeadingIds({
|
|
6
|
-
experimentalHeadingIdCompat
|
|
7
|
-
} = {}) {
|
|
5
|
+
function rehypeHeadingIds() {
|
|
8
6
|
return function(tree, file) {
|
|
9
7
|
const headings = [];
|
|
10
8
|
const frontmatter = file.data.astro?.frontmatter;
|
|
@@ -50,11 +48,7 @@ function rehypeHeadingIds({
|
|
|
50
48
|
});
|
|
51
49
|
node.properties = node.properties || {};
|
|
52
50
|
if (typeof node.properties.id !== "string") {
|
|
53
|
-
|
|
54
|
-
if (!experimentalHeadingIdCompat) {
|
|
55
|
-
if (slug.endsWith("-")) slug = slug.slice(0, -1);
|
|
56
|
-
}
|
|
57
|
-
node.properties.id = slug;
|
|
51
|
+
node.properties.id = slugger.slug(text);
|
|
58
52
|
}
|
|
59
53
|
headings.push({ depth, slug: node.properties.id, text });
|
|
60
54
|
});
|
package/dist/types.d.ts
CHANGED
|
@@ -49,7 +49,6 @@ export interface AstroMarkdownProcessorOptions extends AstroMarkdownOptions {
|
|
|
49
49
|
domains?: string[];
|
|
50
50
|
remotePatterns?: RemotePattern[];
|
|
51
51
|
};
|
|
52
|
-
experimentalHeadingIdCompat?: boolean;
|
|
53
52
|
}
|
|
54
53
|
export interface MarkdownProcessor {
|
|
55
54
|
render: (content: string, opts?: MarkdownProcessorRenderOptions) => Promise<MarkdownProcessorRenderResult>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/markdown-remark",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "withastro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"github-slugger": "^2.0.0",
|
|
29
29
|
"hast-util-from-html": "^2.0.3",
|
|
30
30
|
"hast-util-to-text": "^4.0.2",
|
|
31
|
-
"import-meta-resolve": "^4.2.0",
|
|
32
31
|
"js-yaml": "^4.1.0",
|
|
33
32
|
"mdast-util-definitions": "^6.0.0",
|
|
34
33
|
"rehype-raw": "^7.0.0",
|
|
@@ -37,15 +36,15 @@
|
|
|
37
36
|
"remark-parse": "^11.0.0",
|
|
38
37
|
"remark-rehype": "^11.1.2",
|
|
39
38
|
"remark-smartypants": "^3.0.2",
|
|
40
|
-
"shiki": "^3.
|
|
39
|
+
"shiki": "^3.13.0",
|
|
41
40
|
"smol-toml": "^1.4.2",
|
|
42
41
|
"unified": "^11.0.5",
|
|
43
42
|
"unist-util-remove-position": "^5.0.0",
|
|
44
43
|
"unist-util-visit": "^5.0.0",
|
|
45
|
-
"unist-util-visit-parents": "^6.0.
|
|
44
|
+
"unist-util-visit-parents": "^6.0.2",
|
|
46
45
|
"vfile": "^6.0.3",
|
|
47
|
-
"@astrojs/
|
|
48
|
-
"@astrojs/
|
|
46
|
+
"@astrojs/prism": "4.0.0-alpha.0",
|
|
47
|
+
"@astrojs/internal-helpers": "0.7.4"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
50
|
"@types/estree": "^1.0.8",
|