I am trying to parse a custom language, Nota (grammar), with Javascript embedded inside it (grammar). For example, this screenshot shows a CM6 editor with a program (left), and the Lezer parse tree (right). In this screenshot, nesting is disabled, so only the top-level language (Nota) is being parsed. Notice that {width: 1px}
has a Js
token.
To enable nesting, I add wrap
parameter to the parser’s configuration:
let wrap = parseMixed((node, _input) => {
if (node.type.id == Js) {
return { parser: js_language.parser };
}
return null;
});
Then this happens:
Notice that:
- Javascript gets the correct syntax highlighting.
- The right square bracket disappeared from the span of
ArgCodeNamed
. - The curly braces of
{Content}
are no longer considered matched.
Any idea where the missing square bracket is going? Am I using parseMixed
incorrectly? What seems strange is that using parseMixed seems to be affecting the parse tree outside of the replaced sub-tree.