On this page
escape-colors
Prev: wispsy | Up: projects | Next: enforce-type
Rel: wispsy, Foundation, recipes
Ref: wispsy on GitHub
Tags: #public #wispsy #project #foundation #tier/core
Role
Dependency-free Python 3.14+ ANSI colors, nested text styles, syntax highlighting, optional terminal Markdown rendering, and portable terminal printing.
Install
python -m pip install escape-colors
# Optional syntax highlighting / terminal Markdown:
python -m pip install "escape-colors[syntax]"
python -m pip install "escape-colors[markdown]"
Quickstart
from escape_colors import ansi_print, blue, escape, escape_ansi
ansi_print("blue(hello world)")
ansi_print("bold(blue(hello red(world) again))")
print(escape_ansi("196(red) bg_232(on dark)"))
print(f"{blue}direct constant{escape}")
When to Reach for It
- Adding nested ANSI styling, syntax highlighting (
escape_colors.syntax.highlight), or terminal Markdown (escape_colors.markdown.markdown_print) without heavy terminal frameworks. - Keeping terminal output portable across macOS, Linux, and Windows VT consoles.
Gotchas & Pitfalls
- Windows VT mode:
ansi_printhandles portable console setup automatically, whereas directprint(f"{blue}...{escape}")on Windows requires enabling VT processing first. - Live ESC bytes in strings:
escape_ansi(...)returns strings containing raw\x1bescape sequences—strip or avoid them when writing structured logs or plain-text files. - Python 3.14+ & optional
astree: Core ANSI styling and terminal Markdown have zero dependencies on Python>=3.14; advanced syntax tree highlighting integrates optionally with astree.
Pairs With
- expose-interface — Formats output for functions exported as CLI programs.
- parse-md & astree — Power the optional
escape-colors[markdown]renderer.
Metadata
type: project-card
slug: escape-colors
org: wispsy
repo: wispsy/escape-colors
package: escape-colors
version: 0.3.0
requires_python: ">=3.14"
layer: foundation
topic: wispsy-foundation
status: active
language: python
source_docs: README.md, docs/
Linked from
- tuts/third_party/python3/wispsy
- wiki/choosing
- wiki/compatibility
- wiki/projects
- wiki/projects/astree
- wiki/projects/carets
- wiki/projects/clownfish
- wiki/projects/ellainng
- wiki/projects/enforce-type
- wiki/projects/expose-interface
- wiki/projects/parse-md
- wiki/projects/prettynb
- wiki/projects/wispsy
- wiki/recipes
- wiki/stack/foundation
Related notes
- wiki/projects/astree Linked here; links to this page; shared tags: #foundation, #project, #tier, #wispsy
- wiki/projects/enforce-type Linked here; links to this page; shared tags: #foundation, #project, #tier, #wispsy
- wiki/projects/parse-md Linked here; links to this page; shared tags: #foundation, #project, #tier, #wispsy
- wiki/projects/expose-interface Linked here; links to this page; shared tags: #project, #tier, #wispsy
- wiki/projects/wispsy Linked here; links to this page; shared tags: #project, #tier, #wispsy
- wiki/stack/foundation Linked here; links to this page; shared tags: #foundation, #tier, #wispsy
- wiki/projects Linked here; links to this page; shared tags: #wispsy
- wiki/recipes Linked here; links to this page; shared tags: #wispsy
- wiki/projects/carets links to this page; shared tags: #project, #tier, #wispsy
- wiki/projects/clownfish links to this page; shared tags: #project, #tier, #wispsy