Skip to main content

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

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 as md)
  • html
  • django_html (aliased as django)
  • django_txt
  • jinja
  • jinja_html
  • css (aliased as style, and styles)
  • scss
  • less
  • sass
  • stylus
  • javascript (aliased as js)
  • jsx (aliased as javascriptreact, and react)
  • typescript (aliased as ts)
  • tsx (aliased as typescriptreact)
  • coffeescript (aliased as coffee)
  • 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

sourcetypes-0.0.4.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

sourcetypes-0.0.4-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

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

Hashes for sourcetypes-0.0.4.tar.gz
Algorithm Hash digest
SHA256 a89258eb5a9d7eb40ed9d189c999a4424e48dd9b67e1780869ecbd42ec6ce51c
MD5 3a9364d9d37315a03872c2e2564287b6
BLAKE2b-256 7379b5265eb581390423382e2ae26275f471a7bce1732bb70ab8567059e4f89b

See more details on using hashes here.

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

Hashes for sourcetypes-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 37a33b0eefe29f46bc157e454ebe9b729b9e5b1d58b700d6349dd46baabdad35
MD5 2732a1bbdece3d286f9fc4d60d26ab79
BLAKE2b-256 5b0aeb388a8a35f4d5545790d519f3c6c8f03c80810ba9f2ed6753ee78496e8a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page