Surely this is possible more elegantly, but by browsing the rich docs and source code I figured I can extract the unstyled string for use e.g. in files like this:
from rich.panel import Panel
from rich.console import Console
s=''.join(s.text for s in Console().render(Panel("test",width=40)))
print(s)
output:
╭──────────────────────────────────────╮
│ test │
╰──────────────────────────────────────╯
Is this the official way to get the unstyled string from a renderable? Or is there another convenience method?