Fix bag 4622 + indents

This commit is contained in:
Kiryl
2021-09-24 16:29:48 +03:00
parent 55ca366583
commit 63b6a3bda3
5 changed files with 15 additions and 16 deletions

View File

@@ -15,11 +15,6 @@ from abc import abstractmethod, ABCMeta
from livecarta_config import LawCartaConfig
from util.helpers import BookLogger, BookStatusWrapper
<<<<<<< HEAD:converter/src/book_solver.py
=======
>>>>>>> develop:converter/src/solver.py
class BookSolver:

View File

@@ -231,8 +231,21 @@ class TagStyleConverter:
style = style.replace('list-style-image', 'list-style-type')
# if tag had already had inline style, add this to style parsed from css
if self.tag.attrs.get('style') and self.tag.attrs['style'] not in style:
style += self.tag.attrs['style']
# hot_fix
negative_text_indent_regexp = re.compile(r'((text-indent:( *-\w+%*);) *(margin-left:( *\w+%*);))|(text-indent:( *-\w+%*);)')
inline_style = self.tag.attrs['style']
has_inline_style_attrs = re.search(negative_text_indent_regexp, inline_style)
has_css_style_attrs = re.search(negative_text_indent_regexp, style)
if has_inline_style_attrs:
if has_inline_style_attrs.group(1):
inline_style = inline_style.replace(has_inline_style_attrs.group(1), 'text-indent: ' + has_inline_style_attrs.group(5))
style = style.replace(has_css_style_attrs.group(1), '')
if has_inline_style_attrs.group(6):
inline_style = inline_style.replace(has_inline_style_attrs.group(6), '')
style = style.replace(has_css_style_attrs.group(6), '')
style += inline_style
return style

View File

@@ -8,11 +8,7 @@ from threading import Event
from bs4 import BeautifulSoup
from html_docx_preprocessor import HTMLDocxPreprocessor
from libra_html2json_converter import LibraHTML2JSONConverter
<<<<<<< HEAD
from book_solver import BookSolver
=======
from solver import BookSolver
>>>>>>> develop
class DocxBook(BookSolver):

View File

@@ -442,7 +442,7 @@ if __name__ == "__main__":
logger_object = BookLogger(name=f'epub', main_logger=logger, book_id=0)
json_converter = EpubConverter('../epub/calibri.epub',
json_converter = EpubConverter('../epub/',
logger=logger_object)
tmp = json_converter.convert_to_dict()

View File

@@ -1,10 +1,5 @@
from epub_converter import EpubConverter
<<<<<<< HEAD
from book_solver import BookSolver
=======
from solver import BookSolver
>>>>>>> develop
class EpubBook(BookSolver):