Skip to main content

uniscript

CI PyPI Python 3.11+ License: MIT

Convert plain strings to Unicode subscript/superscript — no HTML, no LaTeX, no images. Just text.

from uniscript import render

render("t_insp")       # → "tᵢₙₛₚ"
render("E=mc^2")       # → "E=mc²"
render("x^(n+1)")      # → "xⁿ⁺¹"
render(r"x_\beta")     # → "xᵦ"
render(r"\sigma_x")    # → "σₓ"

Works anywhere plain text works: terminals, Slack, Markdown files, Jupyter notebooks, text editors, and Python print().


Installation

pip install uniscript

Or with uv:

uv add uniscript

Usage

render(text) — Auto-parse notation strings

Uses _ for subscript and ^ for superscript, matching standard scientific and mathematical notation:

from uniscript import render

# Subscripts
render("t_insp")     # tᵢₙₛₚ
render("V_O2_max")   # VO₂ₘₐₓ
render("H_2O")       # H₂O
render("CO_2")       # CO₂

# Superscripts & Grouping
render("x^2 + y^2")  # x² + y²
render("x^(n+1)")    # xⁿ⁺¹
render("1^st")       # 1ˢᵗ

Greek Letter Shorthands

render() automatically recognizes LaTeX-style Greek names (\alpha, \beta, \gamma, etc.):

render(r"x_\beta")     # xᵦ
render(r"x^\gamma")    # xᵞ
render(r"\sigma_x")    # σₓ
render(r"\rho_0")      # ρ₀
render(r"E_\gamma^2")  # Eᵧ²

All 48 Greek letters (24 lowercase and 24 uppercase) are supported as shorthands.

Explicit Functions: sub() and sup()

from uniscript import sub, sup

sub("insp")   # ᵢₙₛₚ
sub("0123")   # ₀₁₂₃
sub("(n+1)")  # ₍ₙ₊₁₎
sub("β")      # ᵦ

sup("2")      # ²
sup("n+1")    # ⁿ⁺¹
sup("th")     # ᵗʰ
sup("δ")      # ᵟ

Fallback Behavior

Not every character has a Unicode subscript or superscript equivalent. You can customize the fallback behavior:

from uniscript import sub, FallbackMode

# PASSTHROUGH (default): Leaves unsupported characters untouched
sub("q", fallback=FallbackMode.PASSTHROUGH)  # 'q'

# OMIT: Silently drops unsupported characters
sub("q", fallback=FallbackMode.OMIT)         # ''

# RAISE: Raises SubstitutionError with detailed Unicode code point info
sub("q", fallback=FallbackMode.RAISE)        # raises SubstitutionError

Coverage & Inspection Tools

Check which characters are supported in plain text:

from uniscript import coverage, check

# Get detailed breakdown and percentage
sub_report, sup_report = coverage()
print(sub_report)
# uniscript coverage — subscript
#   Supported  : 32/42 (76%)
#   Unsupported: 10/42
#   ...

# Audit individual characters in an expression
check("t_insp")
# {'t': {'sub': 'ₜ', 'sup': 'ᵗ'}, 'i': {'sub': 'ᵢ', 'sup': 'ⁱ'}, ...}

Command-Line Interface (CLI)

uniscript includes a command-line tool with support for arguments and piped stdin:

# Direct argument parsing
uniscript "t_insp"
# tᵢₙₛₚ

# Piped stdin
echo "E=mc^2" | uniscript
# E=mc²

# Convert entire string to sub/superscript
uniscript --sub "insp"
uniscript --sup "2"

# Inspect character coverage in your terminal
uniscript --coverage
uniscript --coverage --chars lower

Unicode Coverage Summary

Character set Subscript Superscript
Digits 0–9 Full (10/10) Full (10/10)
Letters a–z Partial (17/26: ₐ ₑ ₕ ᵢ ⱼ ₖ ₗ ₘ ₙ ₒ ₚ ᵣ ₛ ₜ ᵤ ᵥ ₓ) Almost full (25/26)
Letters A–Z None Partial (~18)
Symbols + − = ( ) Full Full
Greek letters Partial (β γ ρ φ χ) Partial (β γ δ θ ι φ χ)

Development

See DEVELOPMENT.md for local environment setup, testing, and contribution flow.


License

MIT

Metadata

Release files for uniscript 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uniscript 0.1.1
File Size Uploaded
uniscript-0.1.1.tar.gz 18.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for uniscript 0.1.1
File Interpreter ABI Platform
uniscript-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 34.1 kB

Release files / uniscript-0.1.1.tar.gz

Download URL uniscript-0.1.1.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c0ac59aa104db4b1dde2cc5ec1ed2c4f28e3e62510ad74926d0f8329da9dfe5e
BLAKE2b-256 checksum
How to use checksums
5d66c2f8fea7bb69de1845274be05b471b56233f1e0dce25f7e44d62490c7e15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release files / uniscript-0.1.1-py3-none-any.whl

Download URL uniscript-0.1.1-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5cfec1af8f1ff2d17b129809c39f0ee7b1f17de34980aedb740ecddd48faa0c1
BLAKE2b-256 checksum
How to use checksums
b8e62e3d1419bf9e3b23ebc21e635858fdbde75eec434eb5d1c356d09e7c46ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

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