Extended Embedded LanguagesAdds syntax highlighting to C++, Go, Javascript, TypeScript, Python, Rust, PowerShell, YAML and Nix for strings containing source code. Dozens of languages can be used within the strings such as markup languages (HTML, LaTeX), query languages (SQL, GraphQL), data languages (JSON, YAML), shader languages (GLSL, WSGL), scripts (Shell, Bat) and many more. This Visual Studio Code extension enables syntax highlighting within strings that contain source code. For example, a Python script might have strings containing SQL or HTML or Bash. This plugin will add syntax highlighting, and additionally code folding and language-specific editor features within those strings. This is similar to how you can select syntax highlighting within
Markdown documents using a language specifier (e.g. FeaturesThis plugin extends the syntax highlighting of several host languages in order to highlight embedded sub-languages within strings. You need to specify which language you are using within the string.
How this is done depends on the host language (see below). Once that
is done you can see and edit the embedded language just like you are
editing a standalone file using that language. For example if you are
editing SQL within a C++ document, the VSCode "Toggle Line Comment"
command will prefix lines with Host Language - C++C++ uses raw strings to specify the language. A raw string in C++ looks like
Between the Host language - Javascript and TypeScriptJavascript and TypeScript template strings delimited by backticks
(e.g. As an inline comment before the beginning of the string:
Or as a tagged template, this style expects there to be a function with the name of the language which can process the string (see the tagged template documentation for examples and for an identity template which just returns the input string)
Host language - PythonPython multiline strings do not have custom terminators the way C++,
Perl or other languages do. As such, we rely on leading comments to
identify a language. This comment must be immediately after the Host language - YAMLYAML has block strings that begin with a Host Language - RustRust strings are all multiline. But for syntax embedding purposes we
use the multiline raw strings that begin with Host Language - GoAll Go strings are multi-line, but this extension uses raw strings for code blocks. These are strings that are surrounded by backticks and can contain quote and backslash characters without the need for escaping them (they can not, however, easily contain backticks). These strings must be prefixed with an inline comment indicating the language ID Host language - PowershellIn Powershell you can use here-strings for the code blocks. (e.g. Host language - NixNix multiline strings are delimited by Embedded LanguagesThis extension supports a large number of embedded languages, listed below. The "ID" column shows the IDs you can use in host languages like C++ and YAML where you can specify an ID in the host language. The "Comment" column is for host languages like Python which have no way to indicate the embedded language type directly, and shows what the first characters of the embedded language string needs to be to signal which language you are using.
[^1]: JSON does not support comments, so there is no way to indicate a string is a JSON document within the string. Developer NotesSee CONTRIBUTING.md for adding new languages RequirementsKnown Issues
Release NotesSee CHANGELOG.md for full list of changes |