Getting Started
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.parseto add the above support. - Rich-first:
Color.parsetries Rich's parser first and falls back torich-color-extonly when Rich fails, so colors Rich already understands (e.g. ANSIred) are unchanged. - Nothing is patched at import time; call
install()explicitly.install()anduninstall()are idempotent and thread-safe.
For installation instructions, usage examples, packaging notes and more, see the sections linked from the navigation.