Closed skylize closed 7 years ago
No I'm afraid it's impossible. Once I hand off to another grammar I can't control what it does. I do add a rule to handle interpolations but most grammars remove this as part of their descent into nested rules. It's a bit like monkey patching a function before calling it but then the actual function calls another and I loose control.
It's one of the reasons I use my own grammar for CSS/Styled-components/ and GraphQL, so I can maintain this control.
Very nice feature of being able to parse html or other grammars from template literals, but still a bit annoying that the javascript expressions inside them get parsed as plain strings.
There seem to be quite a lot of mechanics already in place for extracting js from a file parsed by
language-html
. Would it not be realistic to extend this functionality to template strings parsed bylanguage-html
or similar grammar packages?