From 32f5a5eb15ccd693a2a523c71fccab7809ef8159 Mon Sep 17 00:00:00 2001 From: Kiryl Date: Tue, 21 Jun 2022 16:51:23 +0300 Subject: [PATCH] Comments fix --- src/epub_converter/html_epub_preprocessor.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/epub_converter/html_epub_preprocessor.py b/src/epub_converter/html_epub_preprocessor.py index 6944caf..ed90767 100644 --- a/src/epub_converter/html_epub_preprocessor.py +++ b/src/epub_converter/html_epub_preprocessor.py @@ -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

+ _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 with """ 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

- _wrap_strings_with_p(content_tag) # 3. heading removal if remove_title_from_chapter: