From f7cfc7915b45721e44c23e6d01e58ef01ec67b83 Mon Sep 17 00:00:00 2001 From: stephenmk Date: Mon, 10 Apr 2023 19:09:01 -0500 Subject: [PATCH] Strip whitespace from markup --- yomichan/soup.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/yomichan/soup.py b/yomichan/soup.py index 84aeed7..572ce76 100644 --- a/yomichan/soup.py +++ b/yomichan/soup.py @@ -14,7 +14,7 @@ def __get_markup_structure(soup): content = [] for child in soup.children: if child.name is None: - text = child.text.replace("\n", "") + text = __clean(child.text) if text != "": content.append(text) else: @@ -34,6 +34,12 @@ def __get_markup_structure(soup): return node +def __clean(text): + text = text.replace("/", "/") + text = text.strip() + return text + + def __get_attributes(attrs): attributes = {} if "href" in attrs: