CoffeeScript: fix templates in embedded JavaScript code & add escapes
ClosedPublic

Authored by nibags on Jul 22 2018, 8:59 AM.

Details

Summary

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:

Diff Detail

Repository
R216 Syntax Highlighting
Branch
jsemb-coffeescript
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 1203
Build 1216: arc lint + arc unit
nibags created this revision.Jul 22 2018, 8:59 AM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptJul 22 2018, 8:59 AM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
nibags requested review of this revision.Jul 22 2018, 8:59 AM
nibags edited the summary of this revision. (Show Details)Jul 22 2018, 9:18 AM

Makes sense. Can you also increase the version number in the language element?

BTW, do you have commit access? Given your frequent updates, it makes sense if you can push yourself.

dhaumann accepted this revision.Jul 22 2018, 10:35 PM

Besides version number, lgtm.

This revision is now accepted and ready to land.Jul 22 2018, 10:35 PM
nibags updated this revision to Diff 38476.Jul 26 2018, 7:16 AM
  • Increase file version (to 6).

Now I have access to commits... but apparently, you have to accept the latest revision to do so :(

nibags closed this revision.Aug 3 2018, 6:47 AM