Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Python Inline Source Syntax HighlightingNew to Visual Studio Code? Get it now.
Python Inline Source Syntax Highlighting

Python Inline Source Syntax Highlighting

Sam Willis

|
2,977 installs
| (2) | Free
Inline syntax highlighting for Python using type hints.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Python Inline Source Syntax Highlighting

VS Code plugin to add syntax highlight to multi line Python strings using type annotations. Supports html, css, javascript, typescript, sql, graphql, multiple css extension languages, template languages and many more, see below for a full list.

Installation

Install python-inline-source from extensions (ctrl + shift + x or cmd + shift + x on mac).

Also available on marketplace.visualstudio.com

Example

Example

Usage

Use a type decoration named for language that you are using, the simplest for of this is to do something like this:

html = str  # Create an alias of the str type named for the language you are using

my_html_string: html = """
  <h1>Some HTML</h1>
"""

In order to aid with the type decorations the sourcetypes package can be installed (pip install sourcetypes) which allows this for all supported languages:

import sourcetypes

my_html_string: sourcetypes.html = """
  <h1>Some HTML</h1>
"""

The sourcetypes package uses typing.Annotated to annotate the str type with the language used. You can use typing.get_type_hints at runtime to determine the language that a string has been annotated with.

Supported Languages

  • markdown (aliased as md)
  • html
  • django_html (aliased as django)
  • django_txt
  • jinja
  • jinja_html
  • css (aliased as style, and styles)
  • scss
  • less
  • sass
  • stylus
  • javascript (aliased as js)
  • jsx (aliased as javascriptreact, and react)
  • typescript (aliased as ts)
  • tsx (aliased as typescriptreact)
  • coffeescript (aliased as coffee)
  • sql
  • json
  • yaml
  • graphql
  • xml
  • python

Requirements

  • At least Visual Studio Code v1.64.0 recommended, not tested on older versions.

Release Notes

[0.0.2] - 2022-03-13

  • Doc tweaks

[0.0.1] - 2022-03-11

  • Alpha release
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft