diff --git a/html2text/__init__.py b/html2text/__init__.py index 7e1a279..a4115d5 100644 --- a/html2text/__init__.py +++ b/html2text/__init__.py @@ -142,6 +142,7 @@ def feed(self, data: str) -> None: super().feed(data) def handle(self, data: str) -> str: + self.start = True self.feed(data) self.feed("") markdown = self.optwrap(self.finish()) diff --git a/test/test_newlines_on_multiple_calls.py b/test/test_newlines_on_multiple_calls.py new file mode 100644 index 0000000..9c493ed --- /dev/null +++ b/test/test_newlines_on_multiple_calls.py @@ -0,0 +1,12 @@ +import html2text + +# See https://github.com/Alir3z4/html2text/issues/163 for more information. + + +def test_newline_on_multiple_calls(): + h = html2text.HTML2Text() + html = "
test
" + md1 = h.handle(html) + md2 = h.handle(html) + md3 = h.handle(html) + assert md1 == md2 == md3