Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

receive custom attributes. #71

Closed
Flysky12138 opened this issue Jan 29, 2024 · 3 comments
Closed

receive custom attributes. #71

Flysky12138 opened this issue Jan 29, 2024 · 3 comments

Comments

@Flysky12138
Copy link

Flysky12138 commented Jan 29, 2024

```js expanded
***
```
export default function Pre({ children, className, ...props }: React.ComponentProps<'pre'>) {
  console.log(props)
  return null
}

i wanna get expanded

@talatkuyuk
Copy link

talatkuyuk commented Mar 15, 2024

What do you want exactly? Why do you return null in pre component? Do you want to get "expanded" property in code element, or only in pre element? Can you explain what would you like to see in the output html, we need more detail, please.

If you want to implement expandable pre element, you can wrap the "pre" element in a "div" having expandable feature.

@Flysky12138
Copy link
Author

I am using next-mdx-remote. Like this, I want to get the 'expanded' parameter

<MDXRemote
  components={{
    pre: function Pre({ children, className, ...props }: React.ComponentProps<'pre'>) {
      console.log(props.expanded)
      return <pre>{children}</pre>
    }
  }}
  options={{
    rehypePlugins: [rehypeKatex, rehypePrismPlus, rehypeSlug],
    remarkPlugins: [remarkGfm, remarkMath, remarkDirective, remarkDirectiveRehype]
  }}
  source="# h1"
/>

@timlrx
Copy link
Owner

timlrx commented Mar 29, 2024

Hi @Flysky12138 I don't see it as a feature that should be included as part of a highlighting plugin. You could consider including your own remark plugin to transform or store desired attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants