React-markdown: Assign a classname to a child <p> conditionally if that contains an image?

Created on 11 Jul 2018  路  3Comments  路  Source: remarkjs/react-markdown

When the markdown source has an image, which then gets wrapped in a p tag after react-markdown processes, is there any way to assign a className to that p tag, only when it is containing an image?

馃憖 areexternal 馃檵 typquestion

Most helpful comment

Or omit it alltogether. I've struggled with this for a while and it would help a lot to be able to decide if you want images to be wrapped by a paragraph. In my project, I would like the paragraph to be removed since it adds a bunch of padding that I can't remove. (Using CSSinJS so a classname wouldn't help).

All 3 comments

Or omit it alltogether. I've struggled with this for a while and it would help a lot to be able to decide if you want images to be wrapped by a paragraph. In my project, I would like the paragraph to be removed since it adds a bunch of padding that I can't remove. (Using CSSinJS so a classname wouldn't help).

@ehellman Have you seen this workaround?

this would be something that may be best handled with a remark plugin.
you can find more information on plugins here https://unifiedjs.com/learn/
a utility like https://github.com/syntax-tree/unist-util-select may help quickly target any paragraph the contains an image.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Yunnkii picture Yunnkii  路  3Comments

zhenyulin picture zhenyulin  路  3Comments

amalajeyan picture amalajeyan  路  4Comments

ghost picture ghost  路  4Comments

hiteshpatwari picture hiteshpatwari  路  3Comments