diff --git a/tabulate/__init__.py b/tabulate/__init__.py index 12a2950..10ce620 100644 --- a/tabulate/__init__.py +++ b/tabulate/__init__.py @@ -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) diff --git a/test/test_output.py b/test/test_output.py index ea3da87..29c5ed3 100644 --- a/test/test_output.py +++ b/test/test_output.py @@ -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 = [