php(+html) highlighting issue
-
Highlighter is too smart and not smart enough at the same time.
First one - because it looks for html tags inside php’s output operators (or maybe in all php code, didn’t bother with checking that out).
Second one - because it can’t understand that only one branch of “if” is executed.
Here is an example.<div>
<div> <!-- this should be highlighted -->
<?php
if($x==$y) {
echo ‘<div id=“bug1”>’; /* bugged highlight to here */
else
echo ‘<div id=“bug2”>’;
echo ‘</div>’;
}
?>
</div> <!-- bugged highlight from here -->
</div>At the same time folding code blocks seems to work correctly. Any suggestions/solutions?
-
Hello jahsql,
I don’t quite understand what you mean by
Second one - because it can’t understand that only one branch of “if” is executed.
Well, I understand what you are saying but I don’t see how a lexer should
know if parts of a code get executed or not. A lexer should tokenize
the code and color each token in regards to the defined rules.
That the lexer gets confused by your code doesn’t surprise me as you
have four open but only three closing tags.
And php/html lexer has increased complexity as the lexer needs to
satisfy php and html code together.Any suggestions/solutions?
<div> <div> <!-- this should be highlighted --> <?php if($x==$y) { echo ‘<div id=“bug1”>’; /* bugged highlight to here */ echo ‘</div>’; else echo ‘<div id=“bug2”>’; echo ‘</div>’; } ?> </div> <!-- bugged highlight from here --> </div>
Maybe I didn’t get the point but this are my two cents worth.
Cheers
Claudia