What is the method to highlight HTML syntax in JavaScript string literals using Sublime Text?

I’m looking for a Sublime Text package that allows for syntax highlighting of HTML code embedded within JavaScript string literals.

(Please note, I am specifically interested in highlighting HTML within JavaScript strings, not general syntax highlighting.)

Currently, I’m developing Angular components that utilize inline templates.

angular.module(‘componentModule’, ).component(‘exampleComponent’, { template: <div>Example Content</div> });

I need to ensure that the HTML within these ES6 template literals is highlighted appropriately.

To highlight HTML within JavaScript string literals in Sublime Text, especially for inline templates in Angular components, the JS Custom package is an ideal solution. Here's a step-by-step guide to setting it up:

  1. Install JS Custom:
    • Launch Sublime Text.
    • If you don't have Package Control installed, go to Tools > Install Package Control.
    • Next, head to Preferences > Package Control > Install Package.
    • Search for and install JS Custom.
  2. Configure JS Custom:
    • Locate or create the js_custom.sublime-settings file in your User package directory.
    • Add a custom syntax configuration like this:
    {
      "configurations": {
        "CustomJS": {
          "file_extensions": ["js"],
          "custom_template_tags": {
            "tagged_templates": {
              "html": {
                "begin": "<",
                "end": "(?=>)",
                "captures": {
                  "Whitespace": "^(\\s*)",
                  "Comment": "

To achieve syntax highlighting of HTML within JavaScript string literals in Sublime Text, particularly with ES6 template literals, you can utilize the “JS Custom” package. This package provides customizable syntax highlighting that can be adjusted to your needs.

  1. Install the JS Custom Package:

    • Open Sublime Text.
    • Go to Tools > Install Package Control if you haven’t already.
    • Once Package Control is installed, navigate to Preferences > Package Control > Install Package.
    • Search for JS Custom and install it.
  2. Configure JS Custom:

    • After installation, you need to configure it to recognize HTML within template strings. Create or edit a configuration file named js_custom.sublime-settings in the User package directory.
    • Define a custom syntax as follows:
{
    "configurations": {
        "CustomJS": {
            "file_extensions": ["js"],
            "custom_template_tags": {
                "tagged_templates": {
                    "html": {
                        "begin": "<",
                        "end": "(?=>)",
                        "captures": {
                            "Whitespace": "^(\s*)",
                            "Comment": "<!--",
                            "TagName": "[a-zA-Z]+(?=\s|>)",
                            "AttributeName": "[-:\w]+" 
                        }
                    }
                }
            }
        }
    }
}
  1. Apply the Custom Syntax:
    • In your JavaScript or Angular files with template literals, make sure to select the new “CustomJS” syntax under View > Syntax > Open all with current extension as... and choose “CustomJS” from the syntax list.

The configuration above ensures that when you use ES6 template literals for inline HTML, the content will be correctly highlighted, enhancing the readability of your components within Sublime Text.

For highlighting HTML within JavaScript string literals in Sublime Text, use the "JS Custom" package. It offers customizable syntax highlighting to suit your needs.

  1. Install JS Custom:
    • Open Sublime Text.
    • Go to Tools > Install Package Control (if not already installed).
    • Navigate to Preferences > Package Control > Install Package.
    • Search for JS Custom and install it.
  2. Configure JS Custom:
    • Create/edit js_custom.sublime-settings in the User directory.
    • Define the syntax with this:
    {
      "configurations": {
        "CustomJS": {
          "file_extensions": ["js"],
          "custom_template_tags": {
            "tagged_templates": {
              "html": {
                "begin": "<",
                "end": "(?=>)",
                "captures": {
                  "Whitespace": "^(\s*)",
                  "Comment": "