forked from LiveCarta/BookConverter
try except text replacer
This commit is contained in:
@@ -197,10 +197,13 @@ class HtmlPresetsProcessor:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _replace_text(**kwargs):
|
def _replace_text(**kwargs):
|
||||||
|
try:
|
||||||
if re.search(re.compile(kwargs["rule"]["condition"]["text"]), kwargs["found_tag"].string):
|
if re.search(re.compile(kwargs["rule"]["condition"]["text"]), kwargs["found_tag"].string):
|
||||||
new_text = re.sub(re.compile(
|
new_text = re.sub(re.compile(
|
||||||
kwargs["rule"]["condition"]["text"]), kwargs["rule"]["text_to_replace"], kwargs["found_tag"].string)
|
kwargs["rule"]["condition"]["text"]), kwargs["rule"]["text_to_replace"], kwargs["found_tag"].string)
|
||||||
kwargs["found_tag"].string.replace_with(new_text)
|
kwargs["found_tag"].string.replace_with(new_text)
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
|
||||||
def process_tags(self,
|
def process_tags(self,
|
||||||
body_tag: BeautifulSoup,
|
body_tag: BeautifulSoup,
|
||||||
|
|||||||
Reference in New Issue
Block a user