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
6 changes: 1 addition & 5 deletions tabulate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1655,11 +1655,7 @@ def _wrap_text_to_colwidths(
else str(_type(cell, numparse)(cell))
)
)
wrapped = [
"\n".join(wrapper.wrap(line))
for line in casted_cell.splitlines()
if line.strip() != ""
]
wrapped = ["\n".join(wrapper.wrap(line)) for line in casted_cell.splitlines()]
new_row.append("\n".join(wrapped))
else:
new_row.append(cell)
Expand Down
8 changes: 8 additions & 0 deletions test/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ def test_plain_maxcolwidth_autowraps():
assert_equal(expected, result)


def test_maxcolwidth_preserves_blank_lines_inside_cells():
table = [["paragraph one\n\nparagraph two", "note"]]
result = tabulate(table, tablefmt="grid", maxcolwidths=[9, None])
expected = tabulate([["paragraph\none\n\nparagraph\ntwo", "note"]], tablefmt="grid")

assert_equal(expected, result)


def test_plain_maxcolwidth_autowraps_with_sep():
"Output: maxcolwidth will result in autowrapping longer cells and separating line"
table = [
Expand Down