Hello
I’ve been using textmate for a while and love it. Ran into a snag today. When I have multi-level nested code, I don't get syntax highlighting.
I’m writing a PHP WordPress function that dynamically builds JSON-LD in a <script> tag and then adds that code to <head> using the wp_head hook. The problem is that JSON-LD and PHP code is not being syntax highlighted when it’s nested like this. It just shows up as a single color (white in my case).
Here’s a truncated example of the code:
<?php add_action('wp_head', ‘works_jsonld_header'); function works_jsonld_header() { ***variables are being set here*** if (is_singular()){ ?> <script type="application/ld+json”> { "@context": "https://schema.org%E2%80%9D, "@type": "CreativeWork”, "@id": "<?= $works_link ?>”, "name": "<?= $w_title ?>”, "about": "<?= $w_descript ?>”, "accessMode": ["auditory", "textual", "visual”], "creator": { "@type": "Person”, "name": "<?= $short_name ?>”, "image": "<?= $auth_img_url[0] ?>”, "sameAs": [ "<?php echo $auth_link . '"’; if (isset($auth_wiki_p) && $auth_wiki_p !== '' && isset($auth_wiki_s) && $auth_wiki_s !== ''){ echo '"' . $auth_wiki_p . '",’; } else if (isset($auth_wiki_p) && ($auth_wiki_p !== '') && $auth_wiki_s == ''){ echo '"' . $auth_wiki_p . '"’; } if (isset($auth_wiki_s) && $auth_wiki_s !== ''){ echo '"' . $auth_wiki_s . '"’; } ?> ] }, *** extra code here*** } </script> <?php } } ?>
As you can see, this is PHP nested in JSON-LD, that is nested in HTML, that is nested in PHP :) Code works, but there is no syntax highlighting for JSON-LD or PHP within JSON-LD.
Not sure if there is a way to enable this in TextMate or if it would have to be added as a new feature. Since using schema is quickly becoming a standard, and WordPress powers so many sites, I think it would be very useful if this worked.
Thanks