forked from LiveCarta/BookConverter
Change select proc to find_all
This commit is contained in:
@@ -117,7 +117,7 @@ class HtmlPresetsProcessor:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _insert_tag(**kwargs):
|
def _insert_tag(**kwargs):
|
||||||
tag_to_insert = \
|
tag_to_insert = \
|
||||||
kwargs["chapter_tag"].new_tag(kwargs["rule"]["tag_to_insert"])
|
kwargs["body_tag"].new_tag(kwargs["rule"]["tag_to_insert"])
|
||||||
# insert all items that was in tag to subtag and remove from tag
|
# insert all items that was in tag to subtag and remove from tag
|
||||||
for content in reversed(kwargs["tag"].contents):
|
for content in reversed(kwargs["tag"].contents):
|
||||||
tag_to_insert.insert(0, content.extract())
|
tag_to_insert.insert(0, content.extract())
|
||||||
@@ -150,14 +150,15 @@ class HtmlPresetsProcessor:
|
|||||||
if rule["condition"]:
|
if rule["condition"]:
|
||||||
for condition_on_tag in ((k, v) for k, v in rule["condition"].items() if v):
|
for condition_on_tag in ((k, v) for k, v in rule["condition"].items() if v):
|
||||||
if condition_on_tag[0] == "parent_tags":
|
if condition_on_tag[0] == "parent_tags":
|
||||||
for tag in body_tag.select(', '.join([condition_on_tag[1] + " > " + re.sub(r"[\^$]", "", tag)
|
for parent_tag in body_tag.select(condition_on_tag[1]):
|
||||||
for tag in tags])):
|
for tag in parent_tag.find_all([re.compile(tag) for tag in tags]):
|
||||||
tag.parent.attrs.update(tag.attrs)
|
# parent_tag != tag.parent
|
||||||
action(body_tag=body_tag, tag=tag, rule=rule)
|
tag.parent.attrs.update(tag.attrs)
|
||||||
|
action(body_tag=body_tag, tag=tag, rule=rule)
|
||||||
elif condition_on_tag[0] == "child_tags":
|
elif condition_on_tag[0] == "child_tags":
|
||||||
for tag in body_tag.select(', '.join([re.sub(r"[\^$]", "", tag) + condition_on_tag[1]
|
for tag in body_tag.find_all([re.compile(tag) for tag in tags]):
|
||||||
for tag in tags])):
|
if tag.select(condition_on_tag[1]):
|
||||||
action(body_tag=body_tag, tag=tag, rule=rule)
|
action(body_tag=body_tag, tag=tag, rule=rule)
|
||||||
elif condition_on_tag[0] == "attrs":
|
elif condition_on_tag[0] == "attrs":
|
||||||
for attr in rule["condition"]["attrs"]:
|
for attr in rule["condition"]["attrs"]:
|
||||||
for tag in body_tag.find_all([re.compile(tag) for tag in tags],
|
for tag in body_tag.find_all([re.compile(tag) for tag in tags],
|
||||||
|
|||||||
Reference in New Issue
Block a user