diff --git a/website/common/tests/test_utils.py b/website/common/tests/test_utils.py index 6e67e98..5f92a38 100644 --- a/website/common/tests/test_utils.py +++ b/website/common/tests/test_utils.py @@ -101,6 +101,10 @@ class ExtractTextTestCase(SimpleTestCase): extract_text("

Paragraph 1

\n

Paragraph 2

"), "Paragraph 1 Paragraph 2", ) + self.assertEqual( + extract_text("New stuff."), + "New stuff.", + ) def test_plain_text(self) -> None: self.assertEqual(extract_text("Hello there!"), "Hello there!") diff --git a/website/common/utils.py b/website/common/utils.py index 06a9e38..4ea5a3c 100644 --- a/website/common/utils.py +++ b/website/common/utils.py @@ -76,10 +76,9 @@ def extract_text(html: str) -> str: """ Get the plain text of some HTML. """ - lines = ( - text.strip(" \n") for text in BeautifulSoup(html, "lxml").find_all(text=True) + return ( + BeautifulSoup(html.replace(" str: