Skip to main content

Python Source Code Types For Inline Syntax Highlighting

Project description

Python Inline Source 2: Syntax Highlighting Using Type Annotations

The original Python Inline Source by @JuroOravec

The PyPI package and VSCode extension have been migrated to:

This project enables inline syntax highligting of strings in python source files for multiple languages using type annotations.

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

Python package:

pip install sourcetypes3

VS Code plugin:

Install python-inline-source-2 from extensions (ctrl + shift + x or cmd + shift + x on mac).

Download and install from releases

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.6] - 2025-03-27

  • forked from v0.0.5

Building

see BUILDING.md

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

sourcetypes3-0.0.6.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

sourcetypes3-0.0.6-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file sourcetypes3-0.0.6.tar.gz.

File metadata

  • Download URL: sourcetypes3-0.0.6.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for sourcetypes3-0.0.6.tar.gz
Algorithm Hash digest
SHA256 5846759fda21d66297498169758c1d8667f9569156a20c41ffa563edcdae5990
MD5 0377e608bca98bc9a4eb0681e3491437
BLAKE2b-256 a450048c5f0c8556eb99909c6240ba46a6b8d566ec61b693dd4b11899fb5129b

See more details on using hashes here.

File details

Details for the file sourcetypes3-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: sourcetypes3-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for sourcetypes3-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4b6babfb9c93b785bc85ddc70481f1066305d0f98888f3ef441b0f6545df83b0
MD5 29a4c1df2acae942e637adfd285a7c08
BLAKE2b-256 55465608cb4e7593ca2d6832714b06dfa8704c4cae1db80014f1d391c676f053

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