Honestly, not sure if this is a bug or a feature but I find it confusing when scanning my code for certain functions. Basically, php highlighting for some code (namely functions, from what I’ve noticed) seems to work differently when declared inside of HTML quotes. For example, a normal php function is highlighted as follows in the top line of code, but when used inside of HTML quotes (such as an href or class attributes), functions seem to be recognized as attribute values rather than php, as in the bottom line:
Interesting that it only affects the functions and not other php constructs. I’ve seen a lot of other posts about syntax highlighting in HTML but none about this specifically. Anyone else notice this issue?
I use the One Dark theme, for reference.
EDIT: Here is the fix:
For the One Dark theme, I use the following:
// Fixes php inside of strings
.syntax--string .syntax--source,
.syntax--string .syntax--meta.syntax--embedded.syntax--line {
color: hsl( 220, 14%, 71% );
}
// The above fix affects punctuation in the closing php tag,
// so use this to reset the color accordingly.
.syntax--string .syntax--punctuation.syntax--section.syntax--embedded .syntax--source {
color: hsl( 5, 48%, 51% );
}
I’m not sure if you can use theme variables in style.less
, but either way I didn’t feel like digging into the theme to figure out what those are and I don’t intend to switch themes any time soon. I may submit a pull request on the theme, but in the mean time I hope this helps anyone else who has the same issue!