Python Inline Source 3: Syntax Highlighting Using Type Annotations
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.
Installation
Python package:
pip install sourcetypes3
VS Code plugin:
Install chrx.python-inline-3 from extensions (ctrl + shift + x or cmd + shift + x
on mac).
Example
Usage
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>
"""
Supported Languages
markdown(aliased asmd)htmldjango_html(aliased asdjango)django_txtjinjajinja_htmlcss(aliased asstyle, andstyles)scsslesssassstylusjavascript(aliased asjs)jsx(aliased asjavascriptreact, andreact)typescript(aliased asts)tsx(aliased astypescriptreact)coffeescript(aliased ascoffee)sqljsonyamlgraphqlxmlpython(aliased aspy)cpp(aliased asc,cc,h,hh, andhpp)golang(aliased asgo)rust(aliased asrs)scm(aliased astree_sitter, andtrs)
Release Notes
[0.0.9] - 2025-03-28
- add Rust
- add tree-sitter (e.g. scm)
[0.0.8] - 2025-03-27
- add C++ & golang
[0.0.7] - 2025-03-27
- allow
\s*around=
[0.0.6] - 2025-03-27
- forked from v0.0.5
Building
see BUILDING.md
TODO
- allow newline continuations // Explicit line joining
Metadata
Release files for sourcetypes3 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sourcetypes3-0.1.0.tar.gz | 3.8 kB | Without provenance | Details for sourcetypes3-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sourcetypes3-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for sourcetypes3-0.1.0-py3-none-any.whl |
Total release size: 7.8 kB
Release files / sourcetypes3-0.1.0.tar.gz
| Download URL | sourcetypes3-0.1.0.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
71b89236516cd095257a07c385ef33807c1261b5205fcbc2674d2ccbd77ecbf6
|
|
BLAKE2b-256 checksum How to use checksums |
539985ade3f627ab26927818f4c2eb05f65272f0b622a6ea0b3660d34ae43d28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.2
|
Release files / sourcetypes3-0.1.0-py3-none-any.whl
| Download URL | sourcetypes3-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a68383c4ef68a2c7000aa8b1fd65581b1f8ce0a1ff7f22a06ed5ee8e2455a64d
|
|
BLAKE2b-256 checksum How to use checksums |
b42aa605a9ad30a55afd7ca808cac5e4fe645c7a4a0f496dd996b2c8a426cb67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.2
|
Security for sourcetypes3 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.