Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tabulate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,6 @@ def _wrap_text_to_colwidths(
wrapped = [
"\n".join(wrapper.wrap(line))
for line in casted_cell.splitlines()
if line.strip() != ""
]
new_row.append("\n".join(wrapped))
else:
Expand Down
16 changes: 16 additions & 0 deletions test/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,22 @@ def test_preserve_line_breaks_with_maxcolwidths():
assert_equal(expected, result)


def test_preserve_blank_lines_with_maxcolwidths():
"Regression: keep blank lines when wrapping cells (github issue #440)"
table = [["foo\n\nbar"]]
expected = "\n".join(
[
"+-----+",
"| foo |",
"| |",
"| bar |",
"+-----+",
]
)
result = tabulate(table, tablefmt="grid", maxcolwidths=10)
assert_equal(expected, result)


def test_maxcolwidths_accepts_list_or_tuple():
"Regression: maxcolwidths can accept a list or a tuple (github issue #214)"
table = [["lorem ipsum dolor sit amet"] * 3]
Expand Down