Python Source Code Types For Inline Syntax Highlighting
Project description
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
)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
Release Notes
[0.0.2] - 2022-03-13
- Doc tweaks
[0.0.1] - 2022-03-11
- Alpha release
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sourcetypes-0.0.4.tar.gz
.
File metadata
- Download URL: sourcetypes-0.0.4.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a89258eb5a9d7eb40ed9d189c999a4424e48dd9b67e1780869ecbd42ec6ce51c |
|
MD5 | 3a9364d9d37315a03872c2e2564287b6 |
|
BLAKE2b-256 | 7379b5265eb581390423382e2ae26275f471a7bce1732bb70ab8567059e4f89b |
File details
Details for the file sourcetypes-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: sourcetypes-0.0.4-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37a33b0eefe29f46bc157e454ebe9b729b9e5b1d58b700d6349dd46baabdad35 |
|
MD5 | 2732a1bbdece3d286f9fc4d60d26ab79 |
|
BLAKE2b-256 | 5b0aeb388a8a35f4d5545790d519f3c6c8f03c80810ba9f2ed6753ee78496e8a |