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

Parsing as className instead of class for React #46

Open
ramon-san opened this issue Mar 29, 2023 · 1 comment
Open

Parsing as className instead of class for React #46

ramon-san opened this issue Mar 29, 2023 · 1 comment

Comments

@ramon-san
Copy link

First of all I'm sorry to open an issue in your GitHub repository! I really appreciate the tool you created and thank you for the work.

Main question

I was wondering if there is a way to parse markdown with this tool and give the attribute className instead of the regular class when using a comment like:

Some paragraph of my markdown file...
<!--rehype:className=regularText-->

The problem with this is that if I render things as .use(rehypeAttr, { properties: 'attr' }), this gives a translation that adds class to the resulting <p> instead of className. I'm asking this in the hope that something already exists, but if not I'd be happy to collaborate on some code for the implementation.

Another question

I was using ChatGPT to help me fix this, and it suggested a syntax similar to this:

.use(rehypeAttr, {
      p: { className: 'text-gray-700 my-10' },
      h1: { className: 'text-3xl font-bold' },
})

Is this valid? Because when I try to use it nothing happens.

@jaywcjlove
Copy link
Owner

jaywcjlove commented Apr 7, 2023

@ramon-san I think it would be better to design the API as follows:

.use(rehypeAttrs, {
  properties: 'attr',
  elements: {
    p: { className: 'text-gray-700 my-10' },
    h1: { className: 'text-3xl font-bold' },
  }
})

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

2 participants