-
Notifications
You must be signed in to change notification settings - Fork 50
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
Question: Is there a way of capturing the class of an existing code block #6
Comments
I think it depends on what you mean by an existing code block and waht the class looks like. My idea for Issue #4 in this repo was auto converting from markdown pasted in like: I need to read up more on how transform works, and how it might work with extending a core block. It seems like it could be something to do from old posts markup depending on the structure of the code. |
Something similar... I've been evaluating using Gutenberg in a blog that has several codeblocks fenced with ``` and the language name, the same way you're thinking about doing it for pasted content. What I'm not sure is whether Gutenberg will work with the converted HTML or the raw Markdown. |
Doing a little more research, it looks like pasted in markdown is handled via the RichText component and specifically this function strips out the extra language info, since the default code block does not have a language attribute. I'll need to think more about how this could work. I commented on a similar issue here, with regards to table losing class names. Maybe during conversion there could be some rules to set the block's additional class field, if that gets set it might be easier to hook into. At least it is pretty straight-forward to go through and set the language on code blocks once they get imported., I've done it for old posts I'm converting on my mkaz.blog site. I convert the classic post to blocks and then click into each code block and select the language. |
I agree it's possible... it's just frustrating. Thank you for taking the time to look into this. |
Is there a way for this block to capture the class of an existing code block? Is this what #4 is designed to support?
If this solves the issue I can then close WordPress/gutenberg/issues/5392
BTW, thanks for tackling this one!
The text was updated successfully, but these errors were encountered: