Syntax Highlighting Gutenberg JSON Block Comments in PHPStorm
I am developing a Wordpress theme using Gutenberg (Full Site Editor) blocks. The blocks appear as commented out JSON blocks in PHP files. Like this:
<!-- wp:group {"tagName":"main","layout":{"type":"constrained","contentSize":"1280px","wideSize":"1280px"}, "style":{"spacing":{"margin":{"top":"0"},"padding":{"top":"var:preset|spacing|large","bottom":"var:preset|spacing|large"}}},"className":"site-content"} -->
I would like PHP to syntax highlight the JSON inside of these comments. I can do so manually by doing Option + Enter > “Inject Language or Reference” > JSON but I would like for PHPStorm to automatically do this in my PHP files. I've tried several iterations of new rules under Settings > Editor > Language Injections but haven't had any luck. Usually the regex pattern I try in the “Value Pattern” field fails and then I can't check the box to activate the rule
Here is a screenshot of what I see:

And what it looks like when I manually force a code injection. Note that this is close to what I would like highlighted but it shouldn't highlight the “wp:group” portion since that is not part of the JSON. I want this to happen automatically without having to do it manually/temporarily

Please sign in to leave a comment.
Hello Becky,
This feature is yet to be implemented. Please upvote WI-77305 to get notified about the updates.