mirror of https://github.com/Textualize/rich.git
special case for Text
This commit is contained in:
parent
a6a54d0bd2
commit
3c811afa91
|
@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Changed
|
||||
|
||||
- Allowed `__rich__` to work recursively
|
||||
- Allowed Text classes to work with sep in print https://github.com/willmcgugan/rich/issues/1689
|
||||
|
||||
## [10.13.0] - 2021-11-07
|
||||
|
||||
|
|
|
@ -1448,6 +1448,8 @@ class Console:
|
|||
renderable, emoji=emoji, markup=markup, highlighter=_highlighter
|
||||
)
|
||||
)
|
||||
elif isinstance(renderable, Text):
|
||||
append_text(renderable)
|
||||
elif isinstance(renderable, ConsoleRenderable):
|
||||
check_text()
|
||||
append(renderable)
|
||||
|
|
|
@ -117,6 +117,24 @@ def test_print():
|
|||
assert console.file.getvalue() == "foo\n"
|
||||
|
||||
|
||||
def test_print_multiple():
|
||||
console = Console(file=io.StringIO(), color_system="truecolor")
|
||||
console.print("foo", "bar")
|
||||
assert console.file.getvalue() == "foo bar\n"
|
||||
|
||||
|
||||
def test_print_text():
|
||||
console = Console(file=io.StringIO(), color_system="truecolor")
|
||||
console.print(Text("foo", style="bold"))
|
||||
assert console.file.getvalue() == "\x1B[1mfoo\x1B[0m\n"
|
||||
|
||||
|
||||
def test_print_text_multiple():
|
||||
console = Console(file=io.StringIO(), color_system="truecolor")
|
||||
console.print(Text("foo", style="bold"), Text("bar"), "baz")
|
||||
assert console.file.getvalue() == "\x1B[1mfoo\x1B[0m bar baz\n"
|
||||
|
||||
|
||||
def test_print_json():
|
||||
console = Console(file=io.StringIO(), color_system="truecolor")
|
||||
console.print_json('[false, true, null, "foo"]', indent=4)
|
||||
|
|
Loading…
Reference in New Issue