[quote=“peter222”]It not really works…
This example works:
<?
foreach ($key as $val) :
echo $val;
endforeach;
?>
but this not:
[code]<? foreach ($key as $val) : ?>
<?=$val;?>
<? endforeach; ?>
[/code][/quote]
Well, it works, but you don’t quite understand the rules. PHP has some quirks.
This is simply a case of dangling brackets. You can see here that the curly braces are not actually matches.
({)(})
The algorithm is very general in BracketHighlighter so that it works with all languages. Stuff like this is a bit tricky to deal with without making some concessions.
So, I have updated the PHP Conditional Keywords on the Beta branch, but in order for this to work for you, you have to ignore <?**, **<?php**, and **?>. If you do this, those will no longer be highlighted, but BracketHighlighter will be able to see things like the foreach and endforeach across the <? ?> punctuation.
So update your BH2 branch and then change your Angle definition to match this in your User/bh_core.sublime-settings file.
// Angle
{
"name": "angle",
"open": "(<)",
"close": "(>)",
"style": "angle",
"scope_exclude": "string", "comment", "keyword.operator", "punctuation.section.embedded.end.php", "punctuation.section.embedded.begin.php"],
"language_filter": "whitelist",
"language_list": "HTML", "HTML 5", "XML", "PHP", "HTML+CFML", "ColdFusion", "ColdFusionCFC"],
"plugin_library": "bh_modules.tags",
"enabled": true
},
That is the best I can do for you.
Edit: I am sure other things can break this like comments right before or right after the php punctuation, but if someone wants to take the time to code up the “perfect” regex, I will pull it in, but this should work in most cases; not sure if there will be any side effects when ignoring <? and ?>. This isn’t guaranteed to be perfect, I kind of expect the community to polish up the regex for their languages and save me from trying to come up with the regex for every language that I might not even use.