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

Are image elements supported? #16

Closed
bj00rn opened this issue Jan 22, 2020 · 8 comments
Closed

Are image elements supported? #16

bj00rn opened this issue Jan 22, 2020 · 8 comments

Comments

@bj00rn
Copy link

bj00rn commented Jan 22, 2020

I use this plugin with react-markdown

I can't seem to get attributes for images, other elements such as <em/> work fine
Are images supported?

Img is not listed in supported.elements but the readme includes the following example:

![alt](img){attrs} / ![alt](img){ height=50 }
@bj00rn bj00rn changed the title Are image element supported? Are image elements supported? Jan 22, 2020
@arobase-che
Copy link
Owner

arobase-che commented Jan 22, 2020 via email

@bj00rn
Copy link
Author

bj00rn commented Jan 22, 2020

@arobase-che thanks for quick reply! 🌹

my problem is that the attributes does not seem to be picked up by my custom renderer function in react-markdown for images. For other elements such as em it works fine.

Issue might very well be specific to my use-case (react-markdown) though.

Below does not work:

![alt](img){ style="color:red" }

Below works fine:

Npm stand for *node*{style="color:red"} packet manager.

@arobase-che
Copy link
Owner

arobase-che commented Jan 22, 2020 via email

@mrm007
Copy link

mrm007 commented Jan 23, 2020

my problem is that the attributes does not seem to be picked up by my custom renderer function in react-markdown for images. For other elements such as em it works fine.

That's unfortunate. react-markdown won't pass the attributes down to your render function (see here). If you set a breakpoint on that line (assuming you have everything else configured correctly) you'll find node.data.hProperties populated by this plugin, but the information doesn't make it to your image renderer.

@arobase-che
Copy link
Owner

Thank you @mrm007 !

I understand the problem but can do anything from my side. I don't understand why they don't pass hProperties to react.

@bj00rn
Copy link
Author

bj00rn commented Jan 23, 2020

@mrm007 you sir, are correct! thank you for the pointers. I´ve opened an issue to pass hProperties to renderers.

@arobase-che upon further investigation I realized that this behavior applies to all element types. like @mrm007 pointed out it's an issue with react-markdown.

Thanks again guys 🎁

@bj00rn bj00rn closed this as completed Jan 23, 2020
@bj00rn
Copy link
Author

bj00rn commented Jan 23, 2020

@arobase-che
Copy link
Owner

arobase-che commented Jan 23, 2020 via email

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