My goal is to provide JS-like syntax highlighting/autocompletion inside mustache html templates inside curly braces.
Initial idea was to adjust lezer-html to make it treat content inside curly braces by nested js parser as if it was javascript (mustache is less powerful than generic javascript, but this would still work for me).
So I added mustache { "{{" nest.jsParser "}}" } into lezer-html grammar entities just to realize that my mustache extension should work over html grammar and have higher priority. E.g. it should blend into text, it could blend across html elements / attributes whatever.
After playing a while with lezer-html parser grammar I concluded that I don’t quite get the way to accomplish my goal.
Found some brief pre-v6 example with overlay parsers CodeMirror: Overlay Parser Demo — maybe you have some extension points in mind to share that I don’t see yet or give some advice how would you start with that.
My current intention (but this may not work out) is to allow Lezer parsers to be extended with ‘injected parsers’, which on specific patterns in the input stop the outer parser and switch to a nested parser.
Just an update on this: I think I have a promising approach, but it’s going to involve a rather big overhaul of Lezer to finish, and given that it’s the summer holiday, it might be a while before I have something to publish.