skillfed

ansimarkup

Produce colored terminal text with an xml-like markup

ansimarkup v2.2.0 158.7K downloads/30d#10,714 on PyPI67
Permissive license BSD 3-Clause License Copyright (c) 2017, Georgi Valkov. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following… (full text in the JSON record) AGING released

What it is and what it does

Ansimarkup is a lightweight wrapper around colorama that lets you write colored and styled terminal output using simple XML-like tags instead of raw ANSI escape codes. You write markup like `<b><red>text</red></b>` and it converts to the corresponding terminal escape sequences. It supports foreground and background colors (named, xterm, hex, and RGB), text styles like bold and dim, nested tags, custom tag definitions, and a logging formatter for the standard library.

The package is designed for convenience with a focus on keeping processing minimal. It includes utilities like ansistring for proper text alignment when using formatted strings, a strip() method to remove markup, and a strict mode to catch mismatched tags. It also works from the command line and on Windows (with colorama initialization). The main limitation is that it does little validation of markup structure—unbalanced nesting will produce incorrect output rather than raising an error.

Use it for:

  • Build CLI tools with colored help text, error messages, and status output using readable markup instead of escape codes.
  • Add colored logging output to Python applications via the included AnsiMarkupFormatter for the logging module.
  • Format terminal progress indicators, warnings, and alerts with different colors and styles for better visibility.
  • Create shell-like scripts in Python that need readable, maintainable colored text without managing raw escape sequences.
  • Align and format colored terminal tables or reports where the delta property helps account for escape sequence length.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Ansimarkup converts XML-like markup tags into ANSI escape sequences for colored and styled terminal text output.

Yes, if you need readable colored terminal output without managing raw escape codes. The low install friction, permissive license, stable classifier, and zero known vulnerabilities make it a safe choice. The aging maintenance status (last commit 191 days ago) is not a blocker for a stable, focused utility, but verify that its known limitations around unbalanced nesting don't affect your use case.

Install

ansimarkup on PyPI

pip

pip install ansimarkup

uv

uv add ansimarkup

poetry

poetry add ansimarkup

Installing ansimarkup

Before you install

Low install friction with a single runtime dependency on colorama. The package is in aging maintenance status with a last commit on 2026-02-04, but carries a Production/Stable classifier and no known vulnerabilities.

License in practice

Released under the BSD 3-Clause License (permissive), which allows commercial and private use with minimal restrictions—only requiring preservation of copyright notice and disclaimer.

Quickstart

from ansimarkup import parse, ansiprint

# Parse markup tags to ANSI escape sequences
result = parse("<b><r>bold red text</r></b>")
print(result)

# Or use ansiprint directly
ansiprint("<b><r>bold red text</r></b>")

On Windows, colorama.init() should be called first to enable ANSI escape sequence support.

Verify before relying

  • Whether the package handles all edge cases beyond the 'happy paths' mentioned in its own limitations section.
  • Current test coverage and whether corner cases like unbalanced nesting are adequately tested.

Package facts

License BSD 3-Clause License Copyright (c) 2017, Georgi Valkov. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following… (full text in the JSON record) (permissive)
Python support supports the current Python release (>=3.6)
Install friction low — pure-Python wheel
Runtime dependencies 1 — colorama
Maintenance aging — 191 days since the last release
Last repo commit
First released
Downloads 158,660/month — #10,714 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: ansimarkup-2.2.0-py3-none-any.whl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Topic :: Software Development :: Libraries

Tags

terminal colors markupansi escape sequencescolored terminal textterminal stylingcommand line colorsxml markup terminalterminal formatting
terminal-uicli-formatting

More Libraries packages