Skip to main content

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

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)

Source distribution for sourcetypes 0.0.4
File Size Uploaded
sourcetypes-0.0.4.tar.gz 2.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sourcetypes 0.0.4
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page