Commit ef4ac8c1 authored by Nuno Martins's avatar Nuno Martins Committed by Christian Hergert

language-specs: fix JS string templates

Fixes JS string templates with interpolations that contain other string
templates, e.g.:

```js
const str = `some ${a ? `a${aa}` : 'b'}`;
```
parent 0dde9e25
......@@ -785,13 +785,20 @@
<keyword>public</keyword>
</context>
<context id="template-string" style-ref="string">
<context id="template-string" style-ref="string" class="string" class-disabled="no-spell-check">
<start>`</start>
<end>`</end>
<include>
<context ref="escape"/>
<context ref="def:line-continue"/>
<!-- FIXME: syntax highlight should go back to none here -->
<context id="template-expression" style-ref="function">
<start>\$\{</start>
<end>\}</end>
<include>
<context ref="js:*"/>
</include>
</context>
</include>
</context>
......
......@@ -26,6 +26,8 @@ x = a /b/ c / d;
"\u00a9" // Unicode escape
'\u{1D306}' // Unicode code point escape
/\cJ/ // Control escape
'\
' // Newline escape
// ES2015 binary and octal numbers:
let binary1 = 0b1010;
......@@ -47,7 +49,16 @@ let bigIntConst = BigInt('1234513123123');
console.log(`The sum of 2 and 2 is ${2 + 2}`);
// Interpolation inside interpolation
let interp = `Hello ${
Math.random() > 0.5
? 'World!'
: `${Math.random() > 0.5 ? 'Alice' : 'Bob'}!`
}`;
let y = 8;
let my_string = `This is a multiline
string that also contains
a template ${y + (4.1 - 2.2)}`;
let escaped = `\b\f\`\\\u00a8\u{12345}\
`;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment