Annot.[HTML->Html, _]

This commit is contained in:
Kiryl
2022-09-06 16:36:35 +03:00
parent ddc45e2d04
commit 83939e43cb
9 changed files with 22 additions and 23 deletions

View File

@@ -13,7 +13,7 @@ from src.util.helpers import BookLogger
from src.livecarta_config import LiveCartaConfig
from src.data_objects import ChapterItem, NavPoint
from src.style_preprocessor import StylePreprocessor
from src.epub_converter.html_epub_processor import HTMLEpubProcessor
from src.epub_converter.html_epub_processor import HtmlEpubProcessor
from src.epub_converter.image_processing import update_images_src_links
from src.epub_converter.footnotes_processing import preprocess_footnotes
from src.tag_inline_style_processor import modify_html_soup_with_css_styles
@@ -21,7 +21,7 @@ from src.tag_inline_style_processor import modify_html_soup_with_css_styles
class EpubConverter:
def __init__(self, book_path, access=None, logger: BookLogger = None,
style_processor: StylePreprocessor = None, html_processor: HTMLEpubProcessor = None):
style_processor: StylePreprocessor = None, html_processor: HtmlEpubProcessor = None):
self.book_path = book_path
self.access = access
self.logger: BookLogger = logger

View File

@@ -5,7 +5,7 @@ from src.book_solver import BookSolver
from src.util.helpers import BookLogger
from src.html_preprocessor import HtmlPreprocessor
from src.style_preprocessor import StylePreprocessor
from src.epub_converter.html_epub_processor import HTMLEpubProcessor
from src.epub_converter.html_epub_processor import HtmlEpubProcessor
from src.epub_converter.epub_converter import EpubConverter
@@ -33,7 +33,7 @@ class EpubBook(BookSolver):
html_preprocessor = HtmlPreprocessor(
logger=self.logger_object, preset_path="presets/epub_presets.json")
style_preprocessor = StylePreprocessor()
html_processor = HTMLEpubProcessor(logger=self.logger_object,
html_processor = HtmlEpubProcessor(logger=self.logger_object,
html_preprocessor=html_preprocessor)
json_converter = EpubConverter(
self.book_path, access=self.access, logger=self.logger_object,
@@ -51,7 +51,7 @@ if __name__ == "__main__":
html_preprocessor = HtmlPreprocessor(
logger=logger_object, preset_path="../../presets/epub_presets.json")
style_preprocessor = StylePreprocessor()
html_processor = HTMLEpubProcessor(logger=logger_object,
html_processor = HtmlEpubProcessor(logger=logger_object,
html_preprocessor=html_preprocessor)
json_converter = EpubConverter(epub_file_path, logger=logger_object,

View File

@@ -3,7 +3,7 @@ from typing import List, Tuple
from bs4 import BeautifulSoup, Tag
def _replace_with_livecarta_anchor_tag(anchor, i):
def replace_with_livecarta_anchor_tag(anchor, i):
"""Function replace noteref_tag(anchor) with new livecarta tag"""
new_tag = BeautifulSoup(features="lxml").new_tag("sup")
new_tag["class"] = "footnote-element"
@@ -75,7 +75,7 @@ def preprocess_footnotes(source_html_tag: Tag, href2soup_html: dict = None, note
if footnote_tag.parent.attrs.get("role") and footnote_tag.parent.attrs.get("role") == "docs-endnote":
footnote_tag = footnote_tag.parent
new_noterefs_tags.append(
_replace_with_livecarta_anchor_tag(noteref_tag, i))
replace_with_livecarta_anchor_tag(noteref_tag, i))
content = footnote_tag.text
# footnote_tag.decompose()
footnotes.append(content)

View File

@@ -7,7 +7,7 @@ from src.util.helpers import BookLogger
from src.html_preprocessor import _preprocess_html
class HTMLEpubProcessor:
class HtmlEpubProcessor:
def __init__(self, logger: BookLogger = None, html_preprocessor=None):
self.logger = logger
self.html_preprocessor = html_preprocessor