Replies: 1 comment
|
The line breaks are produced by If you want a one-line Rich-rendered representation, give the pretty-printer a width large enough for the whole representation rather than removing newlines after rendering. For example: from rich.pretty import Pretty
from rich import print
output = Pretty(
tree,
indent_guides=False,
max_depth=max_depth,
indent_size=indent,
max_width=10_000,
)
print(output, soft_wrap=True)Or, if you need the representation as a string first: from rich.pretty import pretty_repr
text = pretty_repr(tree, max_width=10_000, max_depth=max_depth)I checked the current implementation: One caveat: if an object's own custom |
Uh oh!
There was an error while loading. Please reload this page.
Hey, I'm not sure if it's possible to prevent Rich's print/pretty interface from displaying newlines in the output. Here is my current code and output:
I'd like to keep the highlighted syntax but put everything in a single line (like doing
output.replace("\n", "")) and clean repeated whitespace.All reactions