forked from LiveCarta/BookConverter
try except text replacer
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user