Closed gandm closed 6 years ago
@gandm I might need a bit more background. As far as I know, injection selectors are not meant to be actual grammars that you can select using the Grammar Selector. They're more for auxiliary highlighting (like language-todo). Injection grammars are meant to be selected and need to provide the scopes that they inject in themselves (language-php).
As far as I can see language-php
doesn't work either. It has an injection here that should inject some patterns and eventually the PHP grammar into a scope L:source.js.embedded.html
as a LEFT rule set. So an html file using language-html
with a <?php
inside a <script>
and </script>
which has a scope of source.js.embedded.html
should highlight as PHP but it doesn't.
I've disabled language-javascript
to stop it parsing any source.js
code inside an html file as shown in the image below. PHP isn't highlighted at all which it should be if the above injection of rules was working.
injections
injects into itself, injectionSelector
injects into other grammars. So PHP needs to be the active grammar in order for PHP highlighting to work, while TODO doesn't.
Still doesn't work?
What Atom version are you using?
Atom 1.21.1
Putting a space in front of the <?php
works. Must be an issue with the inject regex patterns in language-php rather than the injection.
I'll close this as it appears to work as designed.
Injection grammars work if using
injectionSelector
but not if usinginjections
It appears grammars are only added as injection grammars if they have the injectionSelector property (first example below) which makes no sense inside a nested set of injections as that property doesn't exist (second example below). Atom adds grammars as Injection grammars here and are only used as rules if they are marked as such here e.g. This works
This doesn't