In CoffeeScript, the character ` (grave accent) is used to insert JavaScript code, but in JavaScript that same character is used for templates. The templantes in embedded JavaScript code are done by prefixing backslashes, as mentioned in the CoffeeScript documentation [1].
Therefore, the syntax highlighting would look like this:
To do this I had to overwrite some JavaScript rules, since some contexts of javascript.xml contain <IncludeRules context="Normal"/> , where you can also insert templates.
Also, the following is added:
- The JavaScript code embedding using 3 backticks [1].
- The escapes supported by CoffeeScript, which are the same as JavaScript [2], with the exception of the octal escapes.
All changes were tested using the CoffeeScript playground [3].
References:
- [1] CoffeeScript. Embedded JavaScript: https://coffeescript.org/#embedded
- [2] JavaScript escapes: https://mathiasbynens.be/notes/javascript-escapes#unicode-code-point
- [3] Try CoffeeScript: https://coffeescript.org/#try