From 9788269337c3e07eb00be0745ff7427bca3a8ef8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 5 Jul 2009 13:08:28 -0600 Subject: [PATCH] MOBI Output: Add option to suppress addition of Table of Contents to end of book, since there appear to be lots of people that think doing this is bad, and I am tired of respoding to them. --- src/calibre/ebooks/mobi/output.py | 12 +++++++----- src/calibre/gui2/convert/mobi_output.ui | 21 ++++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/calibre/ebooks/mobi/output.py b/src/calibre/ebooks/mobi/output.py index 84860d3d0f..4c272f75d1 100644 --- a/src/calibre/ebooks/mobi/output.py +++ b/src/calibre/ebooks/mobi/output.py @@ -24,6 +24,10 @@ class MOBIOutput(OutputFormatPlugin): recommended_value=False, level=OptionRecommendation.LOW, help=_('When present, use author sort field as author.') ), + OptionRecommendation(name='no_inline_toc', + recommended_value=False, level=OptionRecommendation.LOW, + help=_('Don\'t add Table of Contents to end of book. Useful if ' + 'the book has its own table of contents.')), OptionRecommendation(name='toc_title', recommended_value=None, help=_('Title for any generated in-line table of contents.') ), @@ -35,8 +39,6 @@ class MOBIOutput(OutputFormatPlugin): recommended_value=False, level=OptionRecommendation.LOW, help=_('Disable compression of the file contents.') ), - - ]) def convert(self, oeb, output_path, input_plugin, opts, log): @@ -49,8 +51,9 @@ class MOBIOutput(OutputFormatPlugin): from calibre.ebooks.oeb.transforms.htmltoc import HTMLTOCAdder from calibre.customize.ui import plugin_for_input_format imagemax = PALM_MAX_IMAGE_SIZE if opts.rescale_images else None - tocadder = HTMLTOCAdder(title=opts.toc_title) - tocadder(oeb, opts) + if not opts.no_inline_toc: + tocadder = HTMLTOCAdder(title=opts.toc_title) + tocadder(oeb, opts) mangler = CaseMangler() mangler(oeb, opts) rasterizer = SVGRasterizer() @@ -58,7 +61,6 @@ class MOBIOutput(OutputFormatPlugin): mobimlizer = MobiMLizer(ignore_tables=opts.linearize_tables) mobimlizer(oeb, opts) write_page_breaks_after_item = not input_plugin is plugin_for_input_format('cbz') - print 111111, write_page_breaks_after_item writer = MobiWriter(opts, imagemax=imagemax, compression=UNCOMPRESSED if opts.dont_compress else PALMDOC, prefer_author_sort=opts.prefer_author_sort, diff --git a/src/calibre/gui2/convert/mobi_output.ui b/src/calibre/gui2/convert/mobi_output.ui index bc1cd45714..8bd205e9dd 100644 --- a/src/calibre/gui2/convert/mobi_output.ui +++ b/src/calibre/gui2/convert/mobi_output.ui @@ -14,7 +14,7 @@ Form - + &Title for Table of Contents: @@ -24,24 +24,24 @@ - + - + Rescale images for &Palm devices - + Use author &sort for author - + Qt::Vertical @@ -54,20 +54,27 @@ - + Disable compression of the file contents - + Generate a periodical rather than a book + + + + Do not add Table of Contents to book + + +