Print line breaks in in scopes #2974
-
What is the best way to print newlines in a string using I have the following code example: >>> from rich.scope import render_scope
>>> from rich import print
>>>
>>> long_text = """This is
... a text with
... multiple
... line breaks"""
>>> short_text = "Rich is AWESOME"
>>> data = {"long_text": long_text, "shorty": short_text}
>>>
>>> print(render_scope(data))
╭───────────────────────────────────────────────────────────╮
│ long_text = 'This is\na text with\nmultiple\nline breaks' │
│ shorty = 'Rich is AWESOME' │
╰───────────────────────────────────────────────────────────╯
>>> I would like to be able to tell Rich to print the line breaks in the string. So the output would look something like this:
|
Beta Was this translation helpful? Give feedback.
Answered by
willmcgugan
May 29, 2023
Replies: 1 comment 1 reply
-
Only way I can think of to change it would be to copy |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ubaumann
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
render_scope
is intended to display something like arepr
, so it will always escape newlines as Python does.Only way I can think of to change it would be to copy
render_scope
and add a special case for strings.