This repository has been archived by the owner on Dec 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
center-formatting broken with certain escape sequences #55
Comments
Here's a failing unit test: diff --git a/tests/test_width_and_alignment/test_align_and_pad_cell.py b/tests/test_width_and_alignment/test_align_and_pad_cell.py
index e0a928e..aa8bd27 100644
--- a/tests/test_width_and_alignment/test_align_and_pad_cell.py
+++ b/tests/test_width_and_alignment/test_align_and_pad_cell.py
@@ -74,6 +74,9 @@ from terminaltables.width_and_alignment import align_and_pad_cell
('蓝色', 'center', 6, [' 蓝色 ']),
(u'שלום', 'center', 6, [u' \u05e9\u05dc\u05d5\u05dd ']),
(u'معرب', 'center', 6, [u' \u0645\u0639\u0631\u0628 ']),
+
+ ('00:00', 'center', 8, [' 00:00 ']),
+ (colored('00:00', 'blue'), 'center', 8, [' \x1b[34m00:00\x1b[0m ']),
])
def test_width(string, align, width, expected):
"""Test width and horizontal alignment. I don't know which padding you prefer when centering requires left and right padding to be different, but it should be the same for colored and non-colored text. |
Nice to see there's a Pull Request to fix this. Anything you need, @Robpol86 to integrate this? |
@KwadroNaut i suspect the maintainer here might need a little help, see #70 |
FWIW, i ended up switching to tabulate which doesn't have that problem and supports more output formats. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
it seems that the "center" alignment can get confused if there is some escape sequences in a column.
for example, this program will generate this misaligned table:
if the colors are disabled, the column is aligned fine:
not sure what's going on here but it sure seems like the escape sequence calculations go wrong at some point.
PS: I understand this is not exactly a minimal test case but I'm a little tired right now and would rather document this issue at this point. Let me know if you need help minimizing the code or understanding how the table is created.
The text was updated successfully, but these errors were encountered: