forked from LiveCarta/BookConverter
Fix bag 4622 + indents
This commit is contained in:
@@ -15,11 +15,6 @@ from abc import abstractmethod, ABCMeta
|
|||||||
|
|
||||||
from livecarta_config import LawCartaConfig
|
from livecarta_config import LawCartaConfig
|
||||||
from util.helpers import BookLogger, BookStatusWrapper
|
from util.helpers import BookLogger, BookStatusWrapper
|
||||||
<<<<<<< HEAD:converter/src/book_solver.py
|
|
||||||
|
|
||||||
|
|
||||||
=======
|
|
||||||
>>>>>>> develop:converter/src/solver.py
|
|
||||||
|
|
||||||
|
|
||||||
class BookSolver:
|
class BookSolver:
|
||||||
|
|||||||
@@ -231,8 +231,21 @@ class TagStyleConverter:
|
|||||||
style = style.replace('list-style-image', 'list-style-type')
|
style = style.replace('list-style-image', 'list-style-type')
|
||||||
|
|
||||||
# if tag had already had inline style, add this to style parsed from css
|
# 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:
|
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
|
return style
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,7 @@ from threading import Event
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from html_docx_preprocessor import HTMLDocxPreprocessor
|
from html_docx_preprocessor import HTMLDocxPreprocessor
|
||||||
from libra_html2json_converter import LibraHTML2JSONConverter
|
from libra_html2json_converter import LibraHTML2JSONConverter
|
||||||
<<<<<<< HEAD
|
|
||||||
from book_solver import BookSolver
|
from book_solver import BookSolver
|
||||||
=======
|
|
||||||
from solver import BookSolver
|
|
||||||
>>>>>>> develop
|
|
||||||
|
|
||||||
|
|
||||||
class DocxBook(BookSolver):
|
class DocxBook(BookSolver):
|
||||||
|
|||||||
@@ -442,7 +442,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
logger_object = BookLogger(name=f'epub', main_logger=logger, book_id=0)
|
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)
|
logger=logger_object)
|
||||||
tmp = json_converter.convert_to_dict()
|
tmp = json_converter.convert_to_dict()
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
from epub_converter import EpubConverter
|
from epub_converter import EpubConverter
|
||||||
<<<<<<< HEAD
|
|
||||||
from book_solver import BookSolver
|
from book_solver import BookSolver
|
||||||
=======
|
|
||||||
from solver import BookSolver
|
|
||||||
>>>>>>> develop
|
|
||||||
|
|
||||||
|
|
||||||
class EpubBook(BookSolver):
|
class EpubBook(BookSolver):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user