Comments fix

This commit is contained in:
Kiryl
2022-06-21 16:51:23 +03:00
parent 5a237c3974
commit 32f5a5eb15

View File

@@ -62,7 +62,6 @@ def process_structural_tags(chapter_tag: BeautifulSoup) -> BeautifulSoup:
"""Function to replace all tags to correspond livecarta tags"""
for reg_key, to_replace_value in LiveCartaConfig.REPLACE_REGEX_WITH_LIVECARTA_CORRESPOND_TAGS.items():
for key in reg_key:
# text = tag if isinstance(tag, NavigableString) else tag.text
tags = chapter_tag.find_all(re.compile(key))
for tag in tags:
tag.name = to_replace_value
@@ -83,6 +82,12 @@ def process_structural_tags(chapter_tag: BeautifulSoup) -> BeautifulSoup:
while mark.parent != chapter_tag:
mark.parent.unwrap() # todo warning! could reflect on formatting/internal links in some cases
# 1. remove comments
_remove_comments(chapter_tag)
# 2. wrap NavigableString with tag <p>
_wrap_strings_with_p(chapter_tag)
_tags_to_correspond_livecarta_tag(chapter_tag)
_unwrap_tags(chapter_tag)
@@ -294,7 +299,6 @@ def _preprocess_pre_tags(chapter_tag: BeautifulSoup):
pre.append(code)
# todo replace
def _wrap_tag_with_table(chapter_tag, tag_to_be_wrapped, width="100", border="", bg_color=None):
"""Function wraps <tag> with <table>"""
table = chapter_tag.new_tag("table")
@@ -386,11 +390,7 @@ def prepare_content(title_str: str, content_tag: BeautifulSoup, remove_title_fro
prepared content
"""
# 1. remove comments
_remove_comments(content_tag)
# 2. wrap NavigableString with tag <p>
_wrap_strings_with_p(content_tag)
# 3. heading removal
if remove_title_from_chapter: