From 88e0b49e6cfc5a448ae9ba7d100d85574433ad80 Mon Sep 17 00:00:00 2001 From: arjoonn sharma Date: Tue, 22 Jun 2021 22:14:44 +0530 Subject: [PATCH] fix newline bug --- html2text/__init__.py | 1 + test/test_newlines_on_multiple_calls.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) 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 index fe7bcd8..9c493ed 100644 --- a/test/test_newlines_on_multiple_calls.py +++ b/test/test_newlines_on_multiple_calls.py @@ -5,6 +5,8 @@ def test_newline_on_multiple_calls(): h = html2text.HTML2Text() - md1 = h.handle("

test") - md2 = h.handle("

test") - assert md1 == md2 + html = "

test

" + md1 = h.handle(html) + md2 = h.handle(html) + md3 = h.handle(html) + assert md1 == md2 == md3