@astrojs/mdx 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.
package/dist/index.js CHANGED
@@ -58,7 +58,8 @@ function mdx(partialMdxOptions = {}) {
58
58
  });
59
59
  Object.assign(vitePluginMdxOptions, {
60
60
  mdxOptions: resolvedMdxOptions,
61
- srcDir: config.srcDir
61
+ srcDir: config.srcDir,
62
+ experimentalHeadingIdCompat: config.experimental.headingIdCompat
62
63
  });
63
64
  vitePluginMdxOptions = {};
64
65
  }
package/dist/plugins.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { MdxOptions } from './index.js';
2
2
  interface MdxProcessorExtraOptions {
3
3
  sourcemap: boolean;
4
+ experimentalHeadingIdCompat: boolean;
4
5
  }
5
6
  export declare function createMdxProcessor(mdxOptions: MdxOptions, extraOptions: MdxProcessorExtraOptions): import("unified").Processor<import("mdast").Root, import("estree").Program, import("estree").Program, import("estree").Program, string>;
6
7
  export {};
package/dist/plugins.js CHANGED
@@ -19,7 +19,7 @@ const isPerformanceBenchmark = Boolean(process.env.ASTRO_PERFORMANCE_BENCHMARK);
19
19
  function createMdxProcessor(mdxOptions, extraOptions) {
20
20
  return createProcessor({
21
21
  remarkPlugins: getRemarkPlugins(mdxOptions),
22
- rehypePlugins: getRehypePlugins(mdxOptions),
22
+ rehypePlugins: getRehypePlugins(mdxOptions, extraOptions),
23
23
  recmaPlugins: mdxOptions.recmaPlugins,
24
24
  remarkRehypeOptions: mdxOptions.remarkRehype,
25
25
  jsxImportSource: "astro",
@@ -43,23 +43,29 @@ function getRemarkPlugins(mdxOptions) {
43
43
  remarkPlugins.push(...mdxOptions.remarkPlugins, remarkCollectImages);
44
44
  return remarkPlugins;
45
45
  }
46
- function getRehypePlugins(mdxOptions) {
46
+ function getRehypePlugins(mdxOptions, { experimentalHeadingIdCompat }) {
47
47
  let rehypePlugins = [
48
48
  // ensure `data.meta` is preserved in `properties.metastring` for rehype syntax highlighters
49
49
  rehypeMetaString,
50
50
  // rehypeRaw allows custom syntax highlighters to work without added config
51
51
  [rehypeRaw, { passThrough: nodeTypes }]
52
52
  ];
53
- if (!isPerformanceBenchmark) {
54
- if (mdxOptions.syntaxHighlight === "shiki") {
55
- rehypePlugins.push([rehypeShiki, mdxOptions.shikiConfig]);
56
- } else if (mdxOptions.syntaxHighlight === "prism") {
57
- rehypePlugins.push(rehypePrism);
53
+ const syntaxHighlight = mdxOptions.syntaxHighlight;
54
+ if (syntaxHighlight && !isPerformanceBenchmark) {
55
+ const syntaxHighlightType = typeof syntaxHighlight === "string" ? syntaxHighlight : syntaxHighlight?.type;
56
+ const excludeLangs = typeof syntaxHighlight === "object" ? syntaxHighlight?.excludeLangs : void 0;
57
+ if (syntaxHighlightType === "shiki") {
58
+ rehypePlugins.push([rehypeShiki, mdxOptions.shikiConfig, excludeLangs]);
59
+ } else if (syntaxHighlightType === "prism") {
60
+ rehypePlugins.push([rehypePrism, excludeLangs]);
58
61
  }
59
62
  }
60
63
  rehypePlugins.push(...mdxOptions.rehypePlugins, rehypeImageToComponent);
61
64
  if (!isPerformanceBenchmark) {
62
- rehypePlugins.push(rehypeHeadingIds, rehypeInjectHeadingsExport);
65
+ rehypePlugins.push(
66
+ [rehypeHeadingIds, { experimentalHeadingIdCompat }],
67
+ rehypeInjectHeadingsExport
68
+ );
63
69
  }
64
70
  rehypePlugins.push(
65
71
  // Render info from `vfile.data.astro.frontmatter` as JS
@@ -3,5 +3,6 @@ import type { MdxOptions } from './index.js';
3
3
  export interface VitePluginMdxOptions {
4
4
  mdxOptions: MdxOptions;
5
5
  srcDir: URL;
6
+ experimentalHeadingIdCompat: boolean;
6
7
  }
7
8
  export declare function vitePluginMdx(opts: VitePluginMdxOptions): Plugin;
@@ -43,7 +43,10 @@ function vitePluginMdx(opts) {
43
43
  }
44
44
  });
45
45
  if (!processor) {
46
- processor = createMdxProcessor(opts.mdxOptions, { sourcemap: sourcemapEnabled });
46
+ processor = createMdxProcessor(opts.mdxOptions, {
47
+ sourcemap: sourcemapEnabled,
48
+ experimentalHeadingIdCompat: opts.experimentalHeadingIdCompat
49
+ });
47
50
  }
48
51
  try {
49
52
  const compiled = await processor.process(vfile);
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": "4.1.0",
4
+ "version": "4.2.0",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -29,18 +29,18 @@
29
29
  ],
30
30
  "dependencies": {
31
31
  "@mdx-js/mdx": "^3.1.0",
32
- "acorn": "^8.14.0",
32
+ "acorn": "^8.14.1",
33
33
  "es-module-lexer": "^1.6.0",
34
34
  "estree-util-visit": "^2.0.0",
35
- "hast-util-to-html": "^9.0.4",
35
+ "hast-util-to-html": "^9.0.5",
36
36
  "kleur": "^4.1.5",
37
37
  "rehype-raw": "^7.0.0",
38
- "remark-gfm": "^4.0.0",
38
+ "remark-gfm": "^4.0.1",
39
39
  "remark-smartypants": "^3.0.2",
40
40
  "source-map": "^0.7.4",
41
41
  "unist-util-visit": "^5.0.0",
42
42
  "vfile": "^6.0.3",
43
- "@astrojs/markdown-remark": "6.2.0"
43
+ "@astrojs/markdown-remark": "6.3.0"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "astro": "^5.0.0"
@@ -50,7 +50,7 @@
50
50
  "@types/hast": "^3.0.4",
51
51
  "@types/mdast": "^4.0.4",
52
52
  "cheerio": "1.0.0",
53
- "linkedom": "^0.18.7",
53
+ "linkedom": "^0.18.9",
54
54
  "mdast-util-mdx": "^3.0.0",
55
55
  "mdast-util-mdx-jsx": "^3.2.0",
56
56
  "mdast-util-to-string": "^4.0.0",
@@ -62,8 +62,8 @@
62
62
  "remark-toc": "^9.0.0",
63
63
  "shiki": "^1.29.2",
64
64
  "unified": "^11.0.5",
65
- "vite": "^6.0.11",
66
- "astro": "5.4.0",
65
+ "vite": "^6.2.1",
66
+ "astro": "5.5.0",
67
67
  "astro-scripts": "0.0.14"
68
68
  },
69
69
  "engines": {