Skip to content

giladbarnea/more_termcolor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

more_termcolor

Pass unlimited number of colors, color-codes, or attributes

All standard, background, bright, or attribute codes are available (or any combination of them)
Intelligently handles existing colors in the text as to allow adding or combining colors automatically, while ensuring the smallest string size possible

Convenience methods that expose shortcuts to common values (bold('foo'), yellow('bar') etc)
100% compatible with the classic termcolor lib: anything that works with termcolor works the same with more_termcolor

Example

# This is also possible:
from more_termcolor.colors import bold, brightgreen
bold_text = bold('text')
fancy = brightgreen(f'this whole string, including this {bold_text} is bright green')
>>> this whole string, including this text is bright red

Roadmap (work in progress)

- Parse complex color args, such as:
cprint('foo', 'bold bright blue on black')
>>> foo
- pygments-like support for pseudo HTML tags, e.g.:
text = "<magenta>some text<on yellow>that shows</on yellow>what's <bold ul>planned</bold ul></magenta>"
cprint(text) 
>>> some text that shows what's planned
- Custom tags:
text = "<m>some text<oy>that shows</oy>what's <bu>planned</bu></m>"
cprint(text, m='magenta', oy='on yellow', bu='bold ul') 
>>> some text that shows what's planned
- Colorize by regex:
stuff = {'food': 'pizza', 'love': 'wife'}
cprint(stuff, bold=r"'\w+':")
>>> {'food': 'pizza', 'love': 'wife'}

About

Literally more colors, with support for nested colors

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages