diff --git a/src/html_presets_processor.py b/src/html_presets_processor.py index 8905c47..5afe214 100644 --- a/src/html_presets_processor.py +++ b/src/html_presets_processor.py @@ -197,10 +197,13 @@ class HtmlPresetsProcessor: @staticmethod def _replace_text(**kwargs): - if re.search(re.compile(kwargs["rule"]["condition"]["text"]), kwargs["found_tag"].string): - new_text = re.sub(re.compile( - kwargs["rule"]["condition"]["text"]), kwargs["rule"]["text_to_replace"], kwargs["found_tag"].string) - kwargs["found_tag"].string.replace_with(new_text) + try: + if re.search(re.compile(kwargs["rule"]["condition"]["text"]), kwargs["found_tag"].string): + new_text = re.sub(re.compile( + kwargs["rule"]["condition"]["text"]), kwargs["rule"]["text_to_replace"], kwargs["found_tag"].string) + kwargs["found_tag"].string.replace_with(new_text) + except TypeError: + pass def process_tags(self, body_tag: BeautifulSoup,