diff --git a/tabulate/__init__.py b/tabulate/__init__.py index 12a2950..94ef275 100644 --- a/tabulate/__init__.py +++ b/tabulate/__init__.py @@ -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: diff --git a/test/test_regression.py b/test/test_regression.py index 9555676..fbeb076 100644 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -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]