diff --git a/markdownify/__init__.py b/markdownify/__init__.py index 28cdaf6..627d46d 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -675,7 +675,7 @@ def convert_p(self, el, text, parent_tags): new_lines = [] for line in lines: line = line.lstrip(' \t\r\n') - line_no_trailing = line.rstrip() + line_no_trailing = line.rstrip(' \t\r\n') trailing = line[len(line_no_trailing):] line = fill(line, width=self.options['wrap_width'], diff --git a/tests/test_conversions.py b/tests/test_conversions.py index c95483c..5baaf17 100644 --- a/tests/test_conversions.py +++ b/tests/test_conversions.py @@ -285,6 +285,7 @@ def test_p(): assert md('
1234 5678 9012
67890
Second
Third
Fourth') == 'First\n\nSecond\n\nThird\n\nFourth' assert md('x y
', wrap=True, wrap_width=80) == '\n\n\u00a0x y\n\n' + assert md('x y
z
x y
z