Thanks for a quick reply.
I’d like clear my intentions up before asking further questions.
The point is, the injection works perfectly well, but I would like to make one exception for it in the case when the html tag is between the {literal}{/literal} Smarty tags. This is the case when the injection shouldn’t be performed.
Also, I think it’s safer to mention that in the root syntax zone there can occur html tags as well as smarty tags (that’s the point of this template language). {literal} is just to make the compiler ignore whatever Smarty tags there would appear enclosed within this tag.
So, this code should have all ”{foreach}” highlighted:
{foreach}
<script> {foreach}</script>
<style>{foreach}</style>
<div {foreach} id="{foreach}">{foreach}
Whereas this should have none (except for {literal}{/literal} and css and javascript highlighting)
{literal}
{foreach}
<script> {foreach}</script>
<style>{foreach}</style>
<div {foreach} id="{foreach}">{foreach}
{/literal}
(The syntax definitions have been pushed to github recently, so please update before testing so we will get the same results).
When it comes to the selector advice:
Ian Beck - 28 March 2011 05:09 PM
The likeliest problem with your injection selector is that it is too generic. Currently, it will inject that rule into any “tag.open” zone, regardless of whether it is HTML, Smarty, or embedded somewhere in a PHP block (not likely, but possible given that the shipping version of PHP embeds HTML in some strings).
This doesn’t seem to be the point here. The only injected syntax from outside is text.html.basic, and I use the element.<type> pattern for Smarty tags. Thanks for pointing this out for the future, however.
Ian Beck - 28 March 2011 05:09 PM
1) Specifically target immediate descendants of the root zone:
selector="sourcecode.smarty > tags.open"
All HTML tags live in the root syntax zone, whereas all of your Smarty tags are embedded within broader zones (“element.paired.open”, “element.paired.literal”, etc.) so this should restrict your injection to HTML tags.
The problem starts here:
selector="sourcecode.smarty > tag.open"
results in no injection for <tag {$smarty}> at all, although it seems it should match tags which are direct children of the root syntax zone.
Isn’t the comment on wiki (http://wiki.macrabbit.com/index/Syntaxes/) the point here? :
Syntax Injections
[...]
The selector attribute specifies which syntax rules have to be targeted for this particular injection. Note that the selector is interpreted against syntax rules in the syntax definitions, not against the resulting syntax zones.
It seems as if the hierarchy to consider is the one inside the definitions, not the one that the Syntax Inspector shows.
Also, I am not sure whether I understand one thing correctly:
If the zone is named “tag.open.style.html”, should the ”.open.style.html” part be treated as class values to “tag” (which seems more logical to me), or are they just multiple names for the zone, and the “style.html” selector (without the preceding dot) matches them as well? I got this doubts when I read the HTML sugar Itemizers file, which say for example:
<start-selector>html.tag.open:has-child(name:capture(name))</start-selector>
While the words occur in different order in Syntax definitions file, e.g.:
<zone name="tag.open.other.html">
I hope this wasn’t too long.