mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Get rid of the option to control index generation
Index will be generated automatically, wherever the INDEX field exists in the input docx file.
This commit is contained in:
parent
5d4c4b857e
commit
a37fe4b717
@ -19,15 +19,11 @@ class DOCXInput(InputFormatPlugin):
|
||||
help=_('Normally, if a large image is present at the start of the document that looks like a cover, '
|
||||
'it will be removed from the document and used as the cover for created ebook. This option '
|
||||
'turns off that behavior.')),
|
||||
OptionRecommendation(name='docx_index', recommended_value=False,
|
||||
help=_('If there are embedded index markers in the document, this option will use them to create '
|
||||
'an alphabetical index with links to the locations of the markers.')),
|
||||
|
||||
}
|
||||
|
||||
recommendations = set([('page_breaks_before', '/', OptionRecommendation.MED)])
|
||||
|
||||
def convert(self, stream, options, file_ext, log, accelerators):
|
||||
from calibre.ebooks.docx.to_html import Convert
|
||||
return Convert(stream, detect_cover=not options.docx_no_cover, do_index=options.docx_index, log=log)()
|
||||
return Convert(stream, detect_cover=not options.docx_no_cover, log=log)()
|
||||
|
||||
|
@ -387,6 +387,7 @@ class Index(object):
|
||||
We generated the index object in the constructor.
|
||||
This method writes it into the html.
|
||||
"""
|
||||
# TODO: Only do this at locations of the INDEX field in the document
|
||||
body = self.convert.body
|
||||
body.append(add_name('Index', self.title_style))
|
||||
|
||||
|
@ -45,13 +45,12 @@ class Text:
|
||||
|
||||
class Convert(object):
|
||||
|
||||
def __init__(self, path_or_stream, dest_dir=None, log=None, detect_cover=True, do_index=False, notes_text=None):
|
||||
def __init__(self, path_or_stream, dest_dir=None, log=None, detect_cover=True, notes_text=None):
|
||||
self.docx = DOCX(path_or_stream, log=log)
|
||||
self.ms_pat = re.compile(r'\s{2,}')
|
||||
self.ws_pat = re.compile(r'[\n\r\t]')
|
||||
self.log = self.docx.log
|
||||
self.detect_cover = detect_cover
|
||||
self.do_index = do_index
|
||||
self.notes_text = notes_text or _('Notes')
|
||||
self.dest_dir = dest_dir or os.getcwdu()
|
||||
self.mi = self.docx.metadata
|
||||
@ -103,9 +102,7 @@ class Convert(object):
|
||||
# If we are doing an index, do the body part of the processing here.
|
||||
# We need to insert bookmarks at the indexed locations before the
|
||||
# main conversion work.
|
||||
if self.do_index:
|
||||
self.log.debug('Generating index')
|
||||
index = Index(self)
|
||||
index = Index(self)
|
||||
|
||||
self.read_page_properties(doc)
|
||||
self.current_rels = relationships_by_id
|
||||
@ -168,14 +165,13 @@ class Convert(object):
|
||||
parent.text = tabs[-1].tail or ''
|
||||
map(parent.remove, tabs)
|
||||
|
||||
# For an index, we now want to append the index object
|
||||
if self.do_index:
|
||||
index.generate()
|
||||
|
||||
self.images.rid_map = orig_rid_map
|
||||
|
||||
self.resolve_links()
|
||||
|
||||
# For an index, we now want to append the index object
|
||||
index.generate()
|
||||
|
||||
self.styles.cascade(self.layers)
|
||||
|
||||
self.tables.apply_markup(self.object_map, self.page_map)
|
||||
|
@ -18,6 +18,6 @@ class PluginWidget(Widget, Ui_Form):
|
||||
|
||||
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
|
||||
Widget.__init__(self, parent,
|
||||
['docx_no_cover', 'docx_index', ])
|
||||
['docx_no_cover', ])
|
||||
self.initialize_options(get_option, get_help, db, book_id)
|
||||
|
||||
|
@ -21,13 +21,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="opt_docx_index">
|
||||
<property name="text">
|
||||
<string>Generate an alphabetical index from embedded index markers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
Loading…
x
Reference in New Issue
Block a user