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.

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.3.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sourcetypes-0.0.3-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file sourcetypes-0.0.3.tar.gz.

File metadata

  • Download URL: sourcetypes-0.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 25d67dc20f3c822fdbb663baef0d7199496d36ec0be87c4a57c213944ed61a55
MD5 1eb636fa21b6f0618fbb770c692a8d78
BLAKE2b-256 1f4db6a847689aee04a57cd48e5c5772a45c26a3e34067255299aa76bcffadf6

See more details on using hashes here.

File details

Details for the file sourcetypes-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: sourcetypes-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.2 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 44bb13bc45512ac31ff065cba0ecd2fc8c78b181f4c846be95e90458474f0eef
MD5 7785c5cace4aa2d52c59db1d45617c51
BLAKE2b-256 f8e8ab78feec21d3e1ffe0b2e91e03f2a6f508bfd32b09fefa3062a62499b94c

See more details on using hashes here.

Supported by

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