jazzband / prettytable

Display tabular data in a visually appealing ASCII table format
https://pypi.org/project/PrettyTable/
Other
1.36k stars 157 forks source link

Colortable with title leads to broken layout #290

Closed stuertz closed 5 months ago

stuertz commented 6 months ago

What did you do?

printed a colortable with a title

What did you expect to happen?

normal layout as with a prettytable, but colored

What actually happened?

title line explodes in width and one escape sequence was also printed

What versions are you using?

from prettytable import colortable

table = colortable.ColorTable(
    ("A", "B", "C", "D", "E", "f"),
    align="l",
    theme=colortable.Themes.OCEAN,
)
table.title = "Efforts"
table.add_row([1, 2, 3, 4, 5, 6])
print(table)

Creates (colored):

+-----------------------+
|                                                                                                                                                                                       Efforts                                                                                                                                                                                       |
+[36m+---+---+---+---+---+---++
| A | B | C | D | E | f |
+---+---+---+---+---+---+
| 1 | 2 | 3 | 4 | 5 | 6 |
+---+---+---+---+---+---+
hugovk commented 6 months ago

@BD103 Please could you have a look at this?

BD103 commented 6 months ago

My apologies, but I have not contributed in 3 years and do not use Python anymore. If someone else wants to take a look at this, please feel free!

hugovk commented 6 months ago

That's okay, thanks anyway!

av-guy commented 5 months ago

@hugovk

I can take a look at this

av-guy commented 5 months ago

@hugovk

I found the source of the issue, and I am working on a fix to the problem. I will post the details in my pull request.

av-guy commented 5 months ago

@hugovk

Please see https://github.com/jazzband/prettytable/pull/299 for fixes and explanation.