Markup-based terminal coloring engine
Project description
tinting
Markup-based terminal coloring engine.
tinting converts @COLOR[ ... ]@ markup tokens into ANSI 256-color escape
sequences, so you can style terminal output without scattering raw escape
codes through your strings. It supports nested foreground/background colors,
bold/italic/underline modifiers, escaping, visible-length measurement, and
grid-oriented style helpers for terminal UIs.
Installation
pip install tinting
Quick start
from tinting import tprint
tprint("@GRN[success]@ @YEL#[ warning ]@ @*RED[bold red]@")
Markup syntax
| Token | Meaning |
|---|---|
@COLOR[text]@ |
Foreground color COLOR |
@BG#FG[text]@ |
Background BG, foreground FG |
@*COLOR[text]@ |
Bold foreground |
@/COLOR[text]@ |
Italic foreground |
@_COLOR[text]@ |
Underlined foreground |
| `@ | COLOR[ ... ] |
Modifiers *, /, _ can be combined, e.g. @*/BLU[text]@.
Colors
tinting ships a 256-color palette referenced by short codes:
SLV silver GRY gray LGR lightgray BLK black BGE beige
PNK pink CRL coral RED red CRM crimson MRN maroon
DRD darkred YEL yellow ORG orange BRN brown WHT white
GLD gold LME lime OLV olive GRN green FGN forestgreen
TRQ turquoise CYN cyan TEA teal BLU blue NVY navy
IND indigo VIO violet LAV lavender PRP purple PLM plum
MAG magenta RNB rainbow
API
ttext(text, colors=True)- convert markup to ANSI escape sequences.tprint(*args, **kwargs)- print styled text to stdout.tprint_e(*args, **kwargs)- print styled text to stderr.tlen(text)- visible length of a styled string (ignores markup).tesc(text, clean=False)- escape markup tokens so they render literally.tslice(text, end, start=0)- slice a styled string by visible count.Tinting- the engine class holding the palette and compiled pattern.Tinting.by_name- mapping of human-readable names to color codes.TA- grid-oriented style encoding helpers for terminal UIs.
Environment
Color output auto-detection honors the NO_COLOR, FORCE_COLOR, and CI
environment variables, falling back to stdout.isatty().
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tinting-0.1.0.tar.gz.
File metadata
- Download URL: tinting-0.1.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a641e9a1a2877775194bdce9c018a87e938be37a9453a8991f1a17594a37f01
|
|
| MD5 |
071576028342e7ce79f327d11dee087e
|
|
| BLAKE2b-256 |
4d776ac1a87c97ff626485d1bcac1d61a0d8523dd25950446664c72bc7971c57
|
File details
Details for the file tinting-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tinting-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3aa5016a66b9684098fd4a43b8e7b6a2bfbe1c29805b7fd81add4f65b4c8b206
|
|
| MD5 |
c8b9df1f189bf4fef3178aa2ad18b3ca
|
|
| BLAKE2b-256 |
29fd1bf5443825a791272f95e356ac767ee48a1c8cac2e964968f2dd2def4c78
|