The original Python Inline Source by @JuroOravec
The PyPI package and VSCode extension have been migrated to:
- PyPI: sourcetypes3
- VSCode: chrx.python-inline-3
This project enables inline syntax highligting of strings in python source files for multiple languages 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.
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.
- sourcetypes Python Types Package.
- vscode-python-inline-source VS Code Plugin.
pip install sourcetypes3
Install chrx.python-inline-3
from extensions (ctrl + shift + x
or cmd + shift + x
on mac).
Use a type decoration named for language that you are using:
import sourcetypes
my_html_string: sourcetypes.html = """
<h1>Some HTML</h1>
"""
or:
from sourcetypes import html
my_html_string: html = """
<h1>Some HTML</h1>
"""
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
(aliased aspy
)cpp
(aliased asc
,cc
,h
,hh
, andhpp
)golang
(aliased asgo
)rust
(aliased asrs
)scm
(aliased astree_sitter
, andtrs
)
- add Rust
- add tree-sitter (e.g. scm)
- add C++ & golang
- allow
\s*
around=
- forked from v0.0.5
see BUILDING.md
- allow newline continuations // Explicit line joining