🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

sourcetypes3

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sourcetypes3

Python Source Code Types For Inline Syntax Highlighting

0.1.0
PyPI
Maintainers
1

Python Inline Source 3: 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 (aliased as py)
  • cpp (aliased as c, cc, 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

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts