Closed smprather closed 12 months ago
What's happening here, is you're passing things like "[green]PASS[white]"
to PrettyTable, which are just strings. It's doing the width calculation based on that 18-char string.
Then you're fetching the rendered string representation of the whole table, and passing that to Rich.
Rich then converts the Rich-specific [x]
codes into ANSI codes for printing, so "[green]PASS[white]"
turns into a string with four visible characters, and ANSI codes on either side.
Some options:
"[green]PASS[white]"
into a string with ANSI colour codes, then you could try inserting those into the table tooI did some experimenting. I think rich.table.Table is the way to go. Thanks!
Is your feature request related to a problem? Please describe.
I would like to have red/green colored PASS and FAIL elements in my table. I would like to use https://github.com/Textualize/rich markup. The coloring is working, but the column width detection is not filtering out terminal codes.
Describe alternatives you've considered
I tried using a ColorTable thinking maybe you had term-control filtering (for width calculation) enabled in there. But that didn't work with rich.print. I got all kinds of term codes just printed to my terminal as if they weren't prefixed with the [ESC] character.
Thanks!