AnsiMarkup

2.2.0 · active · verified Fri Apr 17

Ansimarkup is a Python library that simplifies producing colored and styled terminal text using an XML-like markup syntax. It translates tags like `<red>Hello</red>` into appropriate ANSI escape codes, supporting various colors, styles (bold, italic, underline), and background colors. The library is currently at version 2.2.0, with stable, albeit infrequent, releases.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates initializing AnsiMarkup to parse text and using `ansiprint` for direct output, showcasing basic colored and styled text.

from ansimarkup import AnsiMarkup

# Create an AnsiMarkup instance
am = AnsiMarkup()

# Use the parse method to convert markup to ANSI colored text
text = am.parse("<red>Error:</red> <bold>Something went wrong!</bold>")
print(text)

# Or, use ansiprint for direct output
from ansimarkup import ansiprint
ansiprint("<green>Success:</green> Operation complete!")

view raw JSON →