Notepad2e
Notepad2e copied to clipboard
Highlight JS templates
JavaScript has a relatively new syntax for strings:
let str = `line1
${eval} line2
${`nested ${1+1}`} line3`
I.e. like 'str' and "str" but multiline and allowing expression interpolation via ${...} (and nested templates via this construct).
Need to add highlighting for such strings. However, Scintilla probably has this already, maybe we should just update our schemes? Also see #180.
Fixed.
Was this implemented from scratch or it's using Scintilla rules? Because highlighting rules are not correct:
- backslash escapes are not correctly handled:
foo backslash backtick baris a single template because backtick is escaped but it's highlighted asfooas a template andbaras a code - nested templates are not recognized - backtick before abc doesn't close the string, it's start of another string since anything inside ${ } is code, not part of the template

Here are the points:
- Scintilla's lexers are used when applying predefined highlighting rules.
- CPP lexer is used for Javascript scheme.
- Recent version of Scintilla still has no correct support of "JS template strings" feature: https://sourceforge.net/p/scintilla/feature-requests/1112/
I see. Let's leave the rule enabled just in case later Scintilla devs get around to implementing proper template highlighting.