From ab5ce00a6ae5f8aa51e0b2ca55411e85564c14dd Mon Sep 17 00:00:00 2001 From: Jeniamakarchik Date: Thu, 16 Apr 2020 13:26:19 +0300 Subject: [PATCH] add fixes for quotes --- src/book.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/book.py b/src/book.py index 369f2df..f233044 100644 --- a/src/book.py +++ b/src/book.py @@ -376,10 +376,7 @@ class Book: if margin_left and margin_right and margin_top and margin_bottom and \ margin_left.group(1) == '0.6' and margin_right.group(1) == '0.6' and \ margin_top.group(1) == '0.14' and margin_bottom.group(1) == '0.11': - blockquote = BeautifulSoup(features='lxml').new_tag('blockquote') - blockquote.append(BeautifulSoup(features='lxml').new_tag('p')) - else: - blockquote = None + p.wrap(BeautifulSoup(features='lxml').new_tag('blockquote')) p.attrs = {} style = '' @@ -394,11 +391,6 @@ class Book: if style: p.attrs['style'] = style - if blockquote: - blockquote.p.attrs = p.attrs - blockquote.p.string = p.text - p.replace_with(blockquote) - def _process_two_columns(self): """ Function to process paragraphs which has two columns layout. @@ -799,8 +791,8 @@ class Book: if __name__ == "__main__": folder_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - file_path = pathlib.Path(os.path.join(folder_path, 'html/0/quote.html')) - out_path = pathlib.Path(os.path.join(folder_path, 'json/quote.json')) + file_path = pathlib.Path(os.path.join(folder_path, 'html/0/quote_img.html')) + out_path = pathlib.Path(os.path.join(folder_path, 'json/quote_img.json')) logging_format = '%(asctime)s - %(levelname)s - %(message)s'