summaryrefslogtreecommitdiff
path: root/packages/integrations/mdx/src/plugins.ts
diff options
context:
space:
mode:
authorGravatar Bjorn Lu <bjornlu.dev@gmail.com> 2022-11-09 21:32:13 +0800
committerGravatar GitHub <noreply@github.com> 2022-11-09 08:32:13 -0500
commitdca762cf734a657d8f126fd6958892b6163a4f67 (patch)
tree25598ee01bdf771106d05186a05432a2b0f8b43d /packages/integrations/mdx/src/plugins.ts
parentdc00ca464865feccd3760b54e0ccc58dbc1e804d (diff)
downloadastro-dca762cf734a657d8f126fd6958892b6163a4f67.tar.gz
astro-dca762cf734a657d8f126fd6958892b6163a4f67.tar.zst
astro-dca762cf734a657d8f126fd6958892b6163a4f67.zip
Preserve code element node meta for rehype syntax highlighters (#5335)
Diffstat (limited to 'packages/integrations/mdx/src/plugins.ts')
-rw-r--r--packages/integrations/mdx/src/plugins.ts3
1 files changed, 3 insertions, 0 deletions
diff --git a/packages/integrations/mdx/src/plugins.ts b/packages/integrations/mdx/src/plugins.ts
index eb53fa629..70c5b1545 100644
--- a/packages/integrations/mdx/src/plugins.ts
+++ b/packages/integrations/mdx/src/plugins.ts
@@ -11,6 +11,7 @@ import remarkSmartypants from 'remark-smartypants';
import type { Data, VFile } from 'vfile';
import { MdxOptions } from './index.js';
import rehypeCollectHeadings from './rehype-collect-headings.js';
+import rehypeMetaString from './rehype-meta-string.js';
import remarkPrism from './remark-prism.js';
import remarkShiki from './remark-shiki.js';
import { jsToTreeNode } from './utils.js';
@@ -150,6 +151,8 @@ export function getRehypePlugins(
let rehypePlugins: PluggableList = [
// getHeadings() is guaranteed by TS, so we can't allow user to override
rehypeCollectHeadings,
+ // ensure `data.meta` is preserved in `properties.metastring` for rehype syntax highlighters
+ rehypeMetaString,
// rehypeRaw allows custom syntax highlighters to work without added config
[rehypeRaw, { passThrough: nodeTypes }] as any,
];