Small refactoring

This commit is contained in:
Kibzik
2023-03-27 14:25:23 +03:00
parent 440122c477
commit 3252131266
3 changed files with 7 additions and 7 deletions

View File

@@ -14,7 +14,7 @@ class HtmlDocxProcessor:
def __init__(self, logger: BookLogger, html_soup: BeautifulSoup, html_preprocessor, style_preprocessor):
self.logger = logger
self.body_tag: BeautifulSoup = BeautifulSoup(str(html_soup.body))
self.html_preprocessor = html_preprocessor
self.html_presets_processor = html_preprocessor
self.style_preprocessor = style_preprocessor
self.content: List[Tag] = []
@@ -252,7 +252,7 @@ class HtmlDocxProcessor:
self._process_headings()
self.logger.log(f".html using presets processing.")
_process_presets(html_preprocessor=self.html_preprocessor,
_process_presets(html_presets_processor=self.html_presets_processor,
html_soup=self.body_tag)
self.content = self.body_tag.body.find_all(recursive=False)

View File

@@ -10,7 +10,7 @@ from src.html_presets_processor import _process_presets
class HtmlEpubProcessor:
def __init__(self, logger: BookLogger = None, html_preprocessor=None):
self.logger = logger
self.html_preprocessor = html_preprocessor
self.html_presets_processor = html_preprocessor
@staticmethod
def prepare_title(title_of_chapter: str) -> str:
@@ -109,10 +109,10 @@ class HtmlEpubProcessor:
len(text_preparing(tag)) != 0 and
re.findall(r"^h[1-5]$", tag.name or chapter_tag.name))
if title_in_text:
self.html_preprocessor.add_span_to_save_ids_for_links(title_in_text[-1], chapter_tag)
self.html_presets_processor.add_span_to_save_ids_for_links(title_in_text[-1], chapter_tag)
title_in_text[-1].extract()
elif text_in_title:
[self.html_preprocessor.add_span_to_save_ids_for_links(tag, chapter_tag) for tag in text_in_title]
[self.html_presets_processor.add_span_to_save_ids_for_links(tag, chapter_tag) for tag in text_in_title]
[tag.extract() for tag in text_in_title]
@staticmethod
@@ -173,7 +173,7 @@ class HtmlEpubProcessor:
self._remove_headings_content(chapter_tag, title)
# 4.
_process_presets(
html_preprocessor=self.html_preprocessor, html_soup=chapter_tag)
html_presets_processor=self.html_presets_processor, html_soup=chapter_tag)
# 5. remove classes that weren't created by converter
self._class_removing(chapter_tag)
return chapter_tag