forked from LiveCarta/BookConverter
Add abil. to replace value of attributes in presets
This commit is contained in:
@@ -147,10 +147,17 @@ class HtmlEpubProcessor:
|
||||
|
||||
@staticmethod
|
||||
def _replace_attr(**kwargs):
|
||||
attr = kwargs["rule"]["attr"]
|
||||
attr_to_replace = kwargs["rule"]["attr_to_replace"]
|
||||
kwargs["tag"][attr_to_replace] = kwargs["tag"][attr]
|
||||
del kwargs["tag"][attr]
|
||||
attr, attr_value =\
|
||||
kwargs["rule"]["attr"]["name"], kwargs["rule"]["attr"]["value"]
|
||||
attr_to_replace, attr_value_to_replace =\
|
||||
kwargs["rule"]["attr_to_replace"]["name"], kwargs["rule"]["attr_to_replace"]["value"]
|
||||
if attr_to_replace:
|
||||
kwargs["tag"][attr_to_replace] = kwargs["tag"][attr]
|
||||
if attr_value_to_replace:
|
||||
kwargs["tag"].attrs[attr_to_replace] = attr_value_to_replace
|
||||
del kwargs["tag"][attr]
|
||||
elif attr_value_to_replace:
|
||||
kwargs["tag"].attrs[attr] = attr_value_to_replace
|
||||
|
||||
@staticmethod
|
||||
def _unwrap_tag(**kwargs):
|
||||
@@ -208,7 +215,7 @@ class HtmlEpubProcessor:
|
||||
elif condition_on_tag[0] == "tags":
|
||||
attr = rule["attr"]
|
||||
for tag in chapter_tag.find_all([re.compile(tag) for tag in tags],
|
||||
{attr: re.compile(r".*")}):
|
||||
{attr['name']: re.compile(fr"{attr['value']}")}):
|
||||
action(chapter_tag=chapter_tag, tag=tag, rule=rule)
|
||||
else:
|
||||
for tag in chapter_tag.find_all([re.compile(tag) for tag in tags]):
|
||||
@@ -316,7 +323,7 @@ class HtmlEpubProcessor:
|
||||
----------
|
||||
title_str: str
|
||||
|
||||
chapter_tag: Tag, soup object
|
||||
chapter_tag: BeautifulSoup, soup object
|
||||
|
||||
remove_title_from_chapter: bool
|
||||
|
||||
|
||||
Reference in New Issue
Block a user