rich
rich copied to clipboard
Add a renderable that transforms text in "child" renderables, add transform-specific versions
Type of changes
- [ ] Bug fix
- [X] New feature
- [ ] Documentation / docstrings
- [ ] Tests
- [ ] Other
Checklist
- [X] I've run the latest black with default args on new code.
- [X] I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
- [X] I've added tests for new code.
- [X] I accept that @willmcgugan may be pedantic in the code review.
Description
This adds a renderable called text_transform.TextTransform
that can be used to apply a given text transformation to a given renderable, and which can also serve as a base class for other text transformations. This also adds child classes of this that upper-case, lower-case and swap-case text.
Examples:
>>> console.print( TextTransform( "Hello, World!", str.upper ) )
HELLO, WORLD!
>>> console.print( Upper( "Hello, World!" ) )
HELLO, WORLD!
>>> console.print( Lower( "Hello, World!" ) )
hello, world!
>>> console.print( SwapCase( "Hello, World!" ) )
hELLO, wORLD!
Codecov Report
Merging #2448 (7a80998) into master (19e518f) will decrease coverage by
3.02%
. The diff coverage is98.57%
.
@@ Coverage Diff @@
## master #2448 +/- ##
==========================================
- Coverage 98.71% 95.68% -3.03%
==========================================
Files 73 73
Lines 7771 7786 +15
==========================================
- Hits 7671 7450 -221
- Misses 100 336 +236
Flag | Coverage Δ | |
---|---|---|
unittests | 95.68% <98.57%> (-3.03%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
rich/default_styles.py | 100.00% <ø> (ø) |
|
rich/logging.py | 100.00% <ø> (ø) |
|
rich/progress.py | 92.76% <ø> (ø) |
|
rich/segment.py | 98.72% <93.10%> (+<0.01%) |
:arrow_up: |
rich/_inspect.py | 100.00% <100.00%> (ø) |
|
rich/box.py | 100.00% <100.00%> (ø) |
|
rich/cells.py | 96.05% <100.00%> (-3.95%) |
:arrow_down: |
rich/color.py | 100.00% <100.00%> (ø) |
|
rich/console.py | 96.71% <100.00%> (-1.58%) |
:arrow_down: |
rich/highlighter.py | 100.00% <100.00%> (ø) |
|
... and 8 more |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
Looks good to me. 👍