You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would assume this is because tabulate is assuming that an n-character string takes n columns to render, which isn't the case with all of Unicode. Here is an example of how combining diacritic handling messed up one of my tables:
In one of my other projects (using Go), I solved the problem by converting table cell contents from a string to a rune array before checking their length (see here).
This looks to be a problem only because of \n.
Without \n the alignment is correct.
wcwidth.wcwidth('\n') returns -1 to indicate the "width" of that character (\n) cannot be determined. I've studied the tabulate function a bit, and though I am not entirely certain, it doesn't look like the possibility of -1 return value from wcwidth.wcwidth is considered?
I can suggest any call to width_fn to be wrapped by max(0, width_fn(... but I'm not so sure, that doesn't explain why it would be four cells off! I can make this attempt at a fix and see if it helps, I think I am wrong though, that would only account for one cell of misalignment, not four!
Activity
hqsz commentedon Dec 17, 2019
I found without alignment is also problem...
Here is example for without alignment(default is maybe left)
raxod502 commentedon Dec 19, 2019
I would assume this is because tabulate is assuming that an n-character string takes n columns to render, which isn't the case with all of Unicode. Here is an example of how combining diacritic handling messed up one of my tables:
In one of my other projects (using Go), I solved the problem by converting table cell contents from a string to a rune array before checking their length (see here).
jquast commentedon May 31, 2020
This looks to be a problem only because of
\n.Without
\nthe alignment is correct.wcwidth.wcwidth('\n')returns -1 to indicate the "width" of that character (\n) cannot be determined. I've studied thetabulatefunction a bit, and though I am not entirely certain, it doesn't look like the possibility of -1 return value fromwcwidth.wcwidthis considered?I can suggest any call to
width_fnto be wrapped bymax(0, width_fn(...but I'm not so sure, that doesn't explain why it would be four cells off! I can make this attempt at a fix and see if it helps, I think I am wrong though, that would only account for one cell of misalignment, not four!add a regression test for issue #28, lint and reformat
Merge pull request astanin#58 from chrd5273/multiline_full_width