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.
Install python-inline-source
from extensions (ctrl + shift + x
or cmd + shift + x
on mac).
Also available on marketplace.visualstudio.com
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.
markdown
(aliased asmd
)html
django_html
(aliased asdjango
)django_txt
jinja
jinja_html
css
(aliased asstyle
, andstyles
)scss
less
sass
stylus
javascript
(aliased asjs
)jsx
(aliased asjavascriptreact
, andreact
)typescript
(aliased asts
)tsx
(aliased astypescriptreact
)coffeescript
(aliased ascoffee
)sql
json
yaml
graphql
xml
python
- At least Visual Studio Code v1.64.0 recommended, not tested on older versions.
- Doc tweaks
- Alpha release