From ca728973f2551b946e80ff2c1f06aeb65bceb433 Mon Sep 17 00:00:00 2001 From: Kiryl Date: Fri, 9 Sep 2022 15:13:02 +0300 Subject: [PATCH] Font -> span out of presets --- presets/docx_presets.json | 5 ----- src/docx_converter/docx2libre_html.py | 2 +- src/docx_converter/html_docx_processor.py | 12 +++++++++++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/presets/docx_presets.json b/presets/docx_presets.json index 3bbee78..fed2d62 100644 --- a/presets/docx_presets.json +++ b/presets/docx_presets.json @@ -43,11 +43,6 @@ { "preset_name": "replacer", "rules": [ - { - "tags": ["^font$"], - "condition": null, - "tag_to_replace": "span" - }, { "tags": ["^h[6-9]$"], "condition": null, diff --git a/src/docx_converter/docx2libre_html.py b/src/docx_converter/docx2libre_html.py index 831d186..e28d98f 100644 --- a/src/docx_converter/docx2libre_html.py +++ b/src/docx_converter/docx2libre_html.py @@ -112,7 +112,7 @@ class Docx2LibreHtml: """Method for reading .html file into beautiful soup tag.""" try: html_text = open(html_path, "r", encoding="utf8").read() - self.logger_object.log("HTML for book has been loaded.") + self.logger_object.log("Html for book has been loaded.") except FileNotFoundError as exc: self.logger_object.log("There is no html to process." "Conversion went wrong or you specified wrong paths.", logging.ERROR) diff --git a/src/docx_converter/html_docx_processor.py b/src/docx_converter/html_docx_processor.py index e52e7a6..5b400db 100644 --- a/src/docx_converter/html_docx_processor.py +++ b/src/docx_converter/html_docx_processor.py @@ -283,9 +283,19 @@ class HtmlDocxProcessor: access=None, html_path: pathlib.Path = "", book_id: int = 0) -> Tuple[List[Tag], List[str], List[Dict[str, Union[str, bool]]]]: - """Process html code to satisfy LiveCarta formatting.""" + """Process html to satisfy LiveCarta formatting.""" self.logger.log("Beginning of processing .html file.") + # Process styles doesn't see because they aren't supported by html + self._font_to_span() + + self.logger.log("Inline style reading.") + self.style_preprocessor.process_inline_styles_in_html_soup( + self.body_tag) + + self.logger.log("Inline style processing.") + modify_html_soup_with_css_styles(self.body_tag) + self.logger.log("Image processing.") self.images = process_images(access, path_to_html=html_path, book_id=book_id, body_tag=self.body_tag)