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 chrx.python-inline-3 from extensions (ctrl + shift + x or cmd + shift + x on mac).

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
  • cpp (aliased as c, h, hh, and hpp)
  • golang (aliased as go)
  • rust (aliased as rs)
  • scm (aliased as tree_sitter, and trs)

Release Notes

[0.0.9] - 2025-03-28

  • add Rust
  • add tree-sitter (e.g. scm)

[0.0.8] - 2025-03-27

  • add C++ & golang

[0.0.7] - 2025-03-27

  • allow \s* around =

[0.0.6] - 2025-03-27

  • forked from v0.0.5

Building

see BUILDING.md

TODO

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.9.tar.gz (3.9 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.9-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sourcetypes3-0.0.9.tar.gz
  • Upload date:
  • Size: 3.9 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.9.tar.gz
Algorithm Hash digest
SHA256 b76a4a65e8e88fc2cb4bfa4458288b40bd19e9076160e7d7db4163fb863a7530
MD5 ea737cdf1a90d78ef2b5c3b24b1be810
BLAKE2b-256 49ffdd24a6ee0c30307fa401b7335967472dee324bd63b2418ea3a5e6b649ea3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sourcetypes3-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 4.1 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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 7367837955a8163e0b6db667e67fa9db53e650e3cfb5234d33808a29dd3c068f
MD5 4ea06560a8ed1a468e365bab500735ca
BLAKE2b-256 3f0bd17716e9ec71af6d50085161038c5a60c7660241e1d4c861d6629765f38f

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