python-tabulate icon indicating copy to clipboard operation
python-tabulate copied to clipboard

Line breaks are stripped when maxcolwidths argument is used

Open DrewDevereux opened this issue 7 months ago • 1 comments

When the maxcolwidths argument is used, explicit line breaks are stripped out and replaced with spaces:

>>> table = [("a\na", 1), ("b", 2)]
>>> print(tabulate(table, tablefmt="grid"))
+---+---+
| a | 1 |
| a |   |
+---+---+
| b | 2 |
+---+---+
>>> print(tabulate(table, tablefmt="grid", maxcolwidths=10))
+-----+---+
| a a | 1 |
+-----+---+
| b   | 2 |
+-----+---+
>>>

DrewDevereux avatar May 17 '25 10:05 DrewDevereux