Skip to main content

Python Source Code Types For Inline Syntax Highlighting

Project description

Python Source Code Types For Inline Syntax Highlighting

The original Python Inline Source by Sam Willis is no longer maintained. Please raise your issues and questions in jurooravec/python-inline-source-2.

The PyPI package and VSCode extension have also been migrated:

This fork is based on v0.0.4.

Type annotations for various languages, when applied to multi line strings will syntax highlighting with the python-inline-source-2 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 sourcetypes2

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.5] - 2024-10-17

  • Add py.typed. #4

[0.0.4] - 2024-10-17

  • Forked from v0.0.4

Dev notes

Install twine and build

pip install twine build

Packaging:

python -m build --sdist --wheel --outdir dist/ .

Publishing:

twine upload --repository pypi dist/* -u __token__ -p <pypi-token>

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

sourcetypes2-0.0.5.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.

sourcetypes2-0.0.5-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file sourcetypes2-0.0.5.tar.gz.

File metadata

  • Download URL: sourcetypes2-0.0.5.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for sourcetypes2-0.0.5.tar.gz
Algorithm Hash digest
SHA256 6d37f8bb1a7bc05891a2c5d3a22f7ba54f734126e261df9faac3bd00dbf76b77
MD5 0abdd43532a2179ca097022e9ed0a802
BLAKE2b-256 c70165372d32e6a3362ff78311a2e8c3963a338cc0b4be7a2c22bff2e28d7535

See more details on using hashes here.

File details

Details for the file sourcetypes2-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: sourcetypes2-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for sourcetypes2-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7b585fdc9d444ae8d4855bac96906c73f3551a387bde667f588440ec978379dc
MD5 83679b1f7be43cdc5ccbfa1a72c584f0
BLAKE2b-256 d6114dfedddac39c11d064e2954f99fde452b0a0b1d1a4438feee41f4411e171

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