forked from LiveCarta/BookConverter
put style processors on general level
This commit is contained in:
@@ -15,15 +15,15 @@ from bs4 import BeautifulSoup, Tag, NavigableString
|
||||
from src.util.helpers import BookLogger
|
||||
from src.livecarta_config import LiveCartaConfig
|
||||
from src.data_objects import ChapterItem, NavPoint
|
||||
from src.epub_converter.css_processor import CSSPreprocessor
|
||||
from src.style_preprocessor import CSSPreprocessor
|
||||
from src.epub_converter.html_epub_processor import HtmlEpubPreprocessor
|
||||
from src.epub_converter.image_processing import update_images_src_links
|
||||
from src.epub_converter.footnotes_processing import preprocess_footnotes
|
||||
from src.epub_converter.tag_inline_style_processor import TagInlineStyleProcessor
|
||||
from src.tag_inline_style_processor import TagInlineStyleProcessor
|
||||
|
||||
|
||||
class EpubConverter:
|
||||
def __init__(self, book_path, access=None, logger=None, css_processor=None, html_processor=None):
|
||||
def __init__(self, book_path, access=None, logger: BookLogger = None, css_processor: CSSPreprocessor = None, html_processor: HtmlEpubPreprocessor = None):
|
||||
self.book_path = book_path
|
||||
self.access = access
|
||||
self.logger: BookLogger = logger
|
||||
@@ -257,7 +257,7 @@ class EpubConverter:
|
||||
|
||||
sub_nodes = []
|
||||
for elem in second:
|
||||
if (bool(re.search('^section$|^part$', first.title.lower()))) and lvl == 1:
|
||||
if (bool(re.search("^section$|^part$", first.title.lower()))) and lvl == 1:
|
||||
self.offset_sub_nodes.append(
|
||||
self.build_adjacency_list_from_toc(elem, lvl))
|
||||
else:
|
||||
@@ -291,7 +291,7 @@ class EpubConverter:
|
||||
return False
|
||||
|
||||
def build_adjacency_list_from_spine(self):
|
||||
def build_manifest_id2html_href() -> dict:
|
||||
def build_manifest_id2html_href() -> Dict[int, str]:
|
||||
links = dict()
|
||||
for item in self.ebooklib_book.get_items_of_type(ebooklib.ITEM_DOCUMENT):
|
||||
links[item.id] = item.file_name
|
||||
@@ -607,7 +607,7 @@ class EpubConverter:
|
||||
self.logger.log(indent + "Process title.")
|
||||
title_preprocessed: str = self.html_processor.prepare_title(title)
|
||||
self.logger.log(indent + "Process content.")
|
||||
content_preprocessed: BeautifulSoup = self.html_processor.prepare_content(
|
||||
content_preprocessed: Union[Tag, BeautifulSoup] = self.html_processor.prepare_content(
|
||||
title_preprocessed, content, remove_title_from_chapter=is_chapter)
|
||||
|
||||
self.book_image_src_path2aws_path = update_images_src_links(content_preprocessed,
|
||||
|
||||
Reference in New Issue
Block a user