WebStorm: how to disable angle brackets stuff highlight in JavaScript strings.

If you write 
`var a = '<bla bla bla>';`
The string will have weird colors in editor.
I have similar strings in my project, this strings have nothing to do with HTML or XML or any angle bracket stuff.

I wish to disable such an 'Forced by IDE language injections support'.

I can remove default background highlight by Settings -> Editor -> Colors & Fonts -> General / Code -> Injected Language fragment.
But I can't get rid of other part of highlight.

There is no 'un-inject language' action choice for this string.

I disabled all checkboxes (and did apply + restart) in Settings-> Editor -> Language Injections.
It did not help.

So how can I disable this force HTML highlight in JavaScipt strings?
2 comments

Please try disabling ' editor.injected.highlighting.enabled' Registry option - see https://youtrack.jetbrains.com/issue/WEB-1475#comment=27-702610

1

A simple way I to get around this is by breaking up '<' and '>' with a call to JavaScript string's concat() function.

Using your example above:

Refactor this:

var a = "<blah bla bla>";

into something like:

var a = "<blah bla".concat(" bla>");

And, boom, highlighting gone!!

BTW, WebStorm will see through this trickery if you try to use the '+' operator to concatenate strings:

var a = "<blah bla" + " bla>"; // WebStorm still sees HTML/XML tag. Trickery failed. 

May I suggest adding a explanatory comment wherever you use this trick, because the next developer that comes along may question your sanity.

0

Please sign in to leave a comment.