From d2e2723d4fd98aff41c0b5fa45ee868ac794ecbb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 7 Oct 2008 20:44:23 -0700 Subject: [PATCH] Make preserving of tag structure when splitting optional --- src/calibre/ebooks/epub/__init__.py | 2 + src/calibre/ebooks/epub/from_any.py | 1 - src/calibre/ebooks/epub/split.py | 2 +- src/calibre/gui2/dialogs/epub.ui | 69 ++++++++++++++++------------- 4 files changed, 41 insertions(+), 33 deletions(-) diff --git a/src/calibre/ebooks/epub/__init__.py b/src/calibre/ebooks/epub/__init__.py index 8b95c5c0a8..66712b98b4 100644 --- a/src/calibre/ebooks/epub/__init__.py +++ b/src/calibre/ebooks/epub/__init__.py @@ -123,6 +123,8 @@ to auto-generate a Table of Contents. help=_('The base font size in pts. Default is %defaultpt. Set to 0 to disable rescaling of fonts.')) layout('remove_paragraph_spacing', ['--remove-paragraph-spacing'], default=True, help=_('Remove spacing between paragraphs. Will not work if the source file forces inter-paragraph spacing.')) + layout('preserve_tag_structure', ['--preserve-tag-structure'], default=False, + help=_('Preserve the HTML tag structure while splitting large HTML files. This is only neccessary if the HTML files contain CSS that uses sibling selectors. Enabling this greatly slows down processing of large HTML files.')) c.add_opt('show_opf', ['--show-opf'], default=False, group='debug', help=_('Print generated OPF file to stdout')) diff --git a/src/calibre/ebooks/epub/from_any.py b/src/calibre/ebooks/epub/from_any.py index e59564cc43..b6d7fbc3db 100644 --- a/src/calibre/ebooks/epub/from_any.py +++ b/src/calibre/ebooks/epub/from_any.py @@ -34,7 +34,6 @@ def mobi2opf(path, tdir, opts): reader = MobiReader(path) reader.extract_content(tdir) files = list(walk(tdir)) - opts.dont_preserve_structure = True opts.encoding = 'utf-8' for f in files: if f.lower().endswith('.opf'): diff --git a/src/calibre/ebooks/epub/split.py b/src/calibre/ebooks/epub/split.py index 1cdb97ec7c..804ee4968f 100644 --- a/src/calibre/ebooks/epub/split.py +++ b/src/calibre/ebooks/epub/split.py @@ -382,7 +382,7 @@ def split(pathtoopf, opts, stylesheet_map): item.set('href', item.get('href').replace('&', '%26')) html_files.append(f) changes = [] - always_remove = getattr(opts, 'dont_preserve_structure', False) + always_remove = not opts.preserve_tag_structure for f in html_files: if os.stat(content(f)).st_size > opts.profile.flow_size: try: diff --git a/src/calibre/gui2/dialogs/epub.ui b/src/calibre/gui2/dialogs/epub.ui index 34836a3b04..88a59cc803 100644 --- a/src/calibre/gui2/dialogs/epub.ui +++ b/src/calibre/gui2/dialogs/epub.ui @@ -77,7 +77,7 @@ - 0 + 1 @@ -89,6 +89,36 @@ Book Cover + + + + + + + + + :/images/book.svg + + + true + + + Qt::AlignCenter + + + + + + + + + Use cover from &source file + + + true + + + @@ -140,36 +170,6 @@ - - - - Use cover from &source file - - - true - - - - - - - - - - - - :/images/book.svg - - - true - - - Qt::AlignCenter - - - - - opt_prefer_metadata_cover @@ -449,6 +449,13 @@ + + + + Preserve &tag structure when splitting + + +