remarkjs / remark-react

Legacy plugin to transform to React — please use `remark-rehype` and `rehype-react` instead
https://unifiedjs.com
MIT License
524 stars 37 forks source link

Laguage type not being passed #59

Closed alesanchezr closed 5 years ago

alesanchezr commented 5 years ago

Let's suppose that the original markdown was a code-block with ```js as opening syntax.

The remarkReactComponents property is not passing the language to the "code" component that y specified, the only property that the component received is an array of children.

        {remark().use(reactRenderer, {
          remarkReactComponents: {
            code: PrismCode
          }
        }).processSync(readme).contents}

My component PrismCode is only receiving the children prop, how can I know that language was this code block defined on?

nrhirani commented 5 years ago

Please refer to the comment in the issue - https://github.com/mapbox/remark-react/issues/23#issuecomment-232691433

You need to pass {sanitize: {attributes: {'*': ['className']}}} to get it working in the remark().use() function.

Hope that helps :)

alesanchezr commented 5 years ago

Thank you @nrhirani !