Respect line breaks in cell content?
SanctusAnimus opened this issue · 3 comments
So consider following table:
table2ascii(
header=["Rank", "Abilities"],
body=[
[1, 'Fury Swipes\nWukong`s Command\nMarksmanship\nOmnislash\nSoul Assumption']
],
alignments=[Alignment.CENTER, Alignment.RIGHT],
column_widths=[6, 19]
)Basically what i want is that every ability name to be on a new line, inside a cell
What i get instead is this:
╔══════════════════════════╗
║ Rank Abilities ║
╟──────────────────────────╢
║ 1 Fury Swipes ║
║ Wukong`s Command ║
║ Marksmanship ║
║ Omnislash Soul ║
║ Assumption ║
╚══════════════════════════╝
Note how Omnislash is merged with Soul in this case, while Assumption is moved to a new line.
Is there a sane way to avoid this (especially without replacing spaces in names with characters or w/e), or tell library to respect line breaks?
Thanks for reporting!
It seems like this issue is caused by the use of textwrap.fill (table_to_ascii.py#L309) which internally removes whitespace before redividing the lines.
We probably could resolve this by checking if the widest line is already smaller than the cell's inner width and not use textwrap.fill when it's not needed such as in your example.
Feel free to let me know what you think of this solution
Thanks for swift response and effort!
I'll be honest, i'm not acknowledged with internals of this library, so whatever fixes the issue itself works for me!