jon
jon

Reputation: 1808

Highlight HTML syntax inside a string?

Is there a way (plugin, option, or tip and trick) to highlight HTML syntax in a JS string?

My document is a .js file, in which I use strings containing HTML code. Is it possible to highlight HTML syntaxe inside these strings?

enter image description here

Upvotes: 41

Views: 19088

Answers (4)

Skirlyx
Skirlyx

Reputation: 321

You can try the extension leet-html. It works fine, without any prefix or comment to add, and not related to any framework.

enter image description here

Upvotes: 6

jon
jon

Reputation: 1808

You can use the extension es6-string-html

Note: You need to add a comment with the language in front of the multiline string

Before and After

Upvotes: 55

AsGoodAsItGets
AsGoodAsItGets

Reputation: 3161

The extension that you suggested requires that you prefix your strings with a comment like /*html*/ or html. I'm working with Angular, and I didn't want to go through all my templates to prefix them, so I found this extension that does it automatically without prefixes:

https://marketplace.visualstudio.com/items?itemName=natewallace.angular2-inline

It is included in the Angular Essentials package by John Papa:

https://marketplace.visualstudio.com/items?itemName=johnpapa.angular-essentials

Upvotes: 11

Related Questions