Python Source Code Types For Inline Syntax Highlighting
Type annotations for various languages, when applied to multi line strings will syntax
highlighting with the python-inline-source VS Code plugin.
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.
On Python versions prior to 3.9 uses typing_extensions to support Annotated types.
Installation
pip install sourcetypes
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
Release Notes
[0.0.2] - 2022-03-13
- Doc tweaks
[0.0.1] - 2022-03-11
- Alpha release
Release files for sourcetypes 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sourcetypes-0.0.4.tar.gz | 2.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sourcetypes-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.9 kB
Release files / sourcetypes-0.0.4.tar.gz
| Download URL | sourcetypes-0.0.4.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a89258eb5a9d7eb40ed9d189c999a4424e48dd9b67e1780869ecbd42ec6ce51c
|
|
BLAKE2b-256 checksum How to use checksums |
7379b5265eb581390423382e2ae26275f471a7bce1732bb70ab8567059e4f89b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.6
|
Release files / sourcetypes-0.0.4-py3-none-any.whl
| Download URL | sourcetypes-0.0.4-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37a33b0eefe29f46bc157e454ebe9b729b9e5b1d58b700d6349dd46baabdad35
|
|
BLAKE2b-256 checksum How to use checksums |
5b0aeb388a8a35f4d5545790d519f3c6c8f03c80810ba9f2ed6753ee78496e8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.6
|