lambda-packages icon indicating copy to clipboard operation
lambda-packages copied to clipboard

Preserving `meta` field of Astro MDX code block

Open pinanek opened this issue 3 years ago • 0 comments

What version of astro are you using?

1.1.5

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the Bug

I try to use a custom syntax highlighter with markdown.syntaxHighlight = false. The official MDX documentation suggests that markdown supports a meta string for code. However, it seems like Astro doesn't preserve the meta field.

```astro title="hello"
---
const weSupportAstro = true;
---

<h1>Hey, what theme is that? Looks nice!</h1>
```
function rehypeMeta() {
  return function transformer(tree) {
    visit(tree, 'element', (node) => {
      if (node.tagName === 'code') {
        console.log(node.data.meta);
      }
    });
  };
}

The meta field is undefined.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-benngb?file=rehype-meta.mjs&on=stackblitz

Participation

  • [ ] I am willing to submit a pull request for this issue.

pinanek avatar Sep 04 '22 04:09 pinanek