diff --git a/src/calibre/ebooks/fb2/fb2.xsl b/src/calibre/ebooks/fb2/fb2.xsl index 7a977aee76..3744388aad 100644 --- a/src/calibre/ebooks/fb2/fb2.xsl +++ b/src/calibre/ebooks/fb2/fb2.xsl @@ -60,6 +60,7 @@
+ diff --git a/src/calibre/ebooks/fb2/input.py b/src/calibre/ebooks/fb2/input.py index d96758a4bd..651b3a62f6 100644 --- a/src/calibre/ebooks/fb2/input.py +++ b/src/calibre/ebooks/fb2/input.py @@ -4,7 +4,7 @@ __copyright__ = '2008, Anatoly Shipitsin ' """ Convert .fb2 files to .lrf """ -import os +import os, re from base64 import b64decode from lxml import etree @@ -26,6 +26,16 @@ class FB2Input(InputFormatPlugin): ('level3_toc', '//h:h3', OptionRecommendation.MED), ]) + options = set([ + OptionRecommendation(name='no_inline_fb2_toc', + recommended_value=False, level=OptionRecommendation.LOW, + help=_('Do not insert a Table of Contents at the beginning of the book.' + ) + ), + ]) + + + def convert(self, stream, options, file_ext, log, accelerators): from calibre.resources import fb2_xsl @@ -39,7 +49,13 @@ class FB2Input(InputFormatPlugin): doc = etree.parse(stream, parser) self.extract_embedded_content(doc) log.debug('Converting XML to HTML...') - styledoc = etree.fromstring(fb2_xsl) + ss = fb2_xsl + if options.no_inline_fb2_toc: + log('Disabling generation of inline FB2 TOC') + ss = re.compile(r'.*', + re.DOTALL).sub('', ss) + + styledoc = etree.fromstring(ss) transform = etree.XSLT(styledoc) result = transform(doc) diff --git a/src/calibre/gui2/convert/fb2_input.py b/src/calibre/gui2/convert/fb2_input.py new file mode 100644 index 0000000000..6f950e7663 --- /dev/null +++ b/src/calibre/gui2/convert/fb2_input.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +__license__ = 'GPL 3' +__copyright__ = '2009, John Schember ' +__docformat__ = 'restructuredtext en' + +from calibre.gui2.convert.fb2_input_ui import Ui_Form +from calibre.gui2.convert import Widget + +class PluginWidget(Widget, Ui_Form): + + TITLE = _('FB2 Input') + HELP = _('Options specific to')+' FB2 '+_('input') + + def __init__(self, parent, get_option, get_help, db=None, book_id=None): + Widget.__init__(self, parent, 'fb2_input', + ['no_inline_fb2_toc']) + self.db, self.book_id = db, book_id + self.initialize_options(get_option, get_help, db, book_id) diff --git a/src/calibre/gui2/convert/fb2_input.ui b/src/calibre/gui2/convert/fb2_input.ui new file mode 100644 index 0000000000..1219e54cf5 --- /dev/null +++ b/src/calibre/gui2/convert/fb2_input.ui @@ -0,0 +1,41 @@ + + + Form + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Qt::Vertical + + + + 20 + 213 + + + + + + + + Do not insert a &Table of Contents at the beginning of the book. + + + + + + + +