js-slang
js-slang copied to clipboard
Editor: Syntax highlighting is erroneous when string contains `&`
Note: There is no error in evaluation.
Reproduction
Not OK
- When the string is
xxxx&xxx
const foo = "a&b
is parsed asvariable.language
and";
is parsed asstring
.
const foo = "a&b";
- When the string is
xxxx&
const foo = "a&";
This string matches the variable.language
regex possibly.
OK
const foo = "ab";
This issue persists as of today.
Should we just remove our custom js-slang syntax highlighting and use default JS one? I don't really see it as a "core" feature to maintain our own syntax highlighting rules (it's only going to get worse if we want to maintain highlighting rules for the other languages).
I think our syntax highlighting should reflect the focus on specific sublanguages, such as Source §1. Learners with prior knowledge are able to see quickly whether the feature they are using is included in the language.