Skip to content

Getting Started

rich-color-ext

rich-color-ext extends the Rich library to parse 3-digit hex colors (#09F→#0099FF, the # is required) and CSS color names (rebeccapurple→#663399). This project allows Rich users to write color names or short hex codes and have them correctly parsed into Rich Color instances.

rich-color-ext parses with Rich's own Color.parse first and only falls back to rich-color-ext when Rich fails (raises ColorParseError).

Key features

  • Parse 3-digit hex colors like #abc → #AABBCC (the leading # is required)
  • Parse CSS color names rebeccapurple, mediumslateblue
  • Lightweight monkey-patch to Rich's Color.parse to add the above support.
  • Rich-first: Color.parse tries Rich's parser first and falls back to rich-color-ext only when Rich fails, so colors Rich already understands (e.g. ANSI red) are unchanged.
  • Nothing is patched at import time; call install() explicitly. install() and uninstall() are idempotent and thread-safe.

For installation instructions, usage examples, packaging notes and more, see the sections linked from the navigation.