From 1059fefe9d526d1600b3b7f622fe97684d78c9b1 Mon Sep 17 00:00:00 2001 From: arjoonn sharma Date: Wed, 23 Jun 2021 10:30:50 +0530 Subject: [PATCH] Squashed commit of the following: commit 88e0b49e6cfc5a448ae9ba7d100d85574433ad80 Author: arjoonn sharma Date: Tue Jun 22 22:14:44 2021 +0530 fix newline bug commit 820b779580f2ef2f040ade6cd6ba577105dc5469 Author: arjoonn sharma Date: Tue Jun 22 21:32:44 2021 +0530 add failing test --- html2text/__init__.py | 1 + test/test_newlines_on_multiple_calls.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 test/test_newlines_on_multiple_calls.py 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