jazzband / prettytable

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

Use `_str_block_width` to calculate title width #232

Open hwmq opened 1 year ago

hwmq commented 1 year ago

https://github.com/jazzband/prettytable/blob/db4a1e36269792b25c29be76f8ce48969b653c5e/src/prettytable/prettytable.py#L1572

Since title width is currently computed using len, zero-width characters in the title contribute to table width. _str_block_width removes some escape codes before calculating width and returns a more appropriate value. I propose replace len(options["title"]) with _str_block_width(options["title"]).

hugovk commented 1 year ago

Please fill out the template:

What did you do?

What did you expect to happen?

What actually happened?

What versions are you using?

Please include code that reproduces the issue.

The best reproductions are self-contained scripts with minimal dependencies.

# code goes here