diff --git a/src/calibre/customize/profiles.py b/src/calibre/customize/profiles.py index 1df2e65f1e..f8fe2a59b4 100644 --- a/src/calibre/customize/profiles.py +++ b/src/calibre/customize/profiles.py @@ -658,13 +658,14 @@ class NookOutput(OutputProfile): class BambookOutput(OutputProfile): + author = 'Li Fanxi' name = 'Sanda Bambook' short_name = 'bambook' description = _('This profile is intended for the Sanda Bambook.') # Screen size is a best guess - screen_size = (800, 600) - comic_screen_size = (700, 540) + screen_size = (600, 800) + comic_screen_size = (540, 700) dpi = 168.451 fbase = 12 fsizes = [10, 12, 14, 16] diff --git a/src/calibre/ebooks/snb/output.py b/src/calibre/ebooks/snb/output.py index 549ee51446..fa8442391b 100644 --- a/src/calibre/ebooks/snb/output.py +++ b/src/calibre/ebooks/snb/output.py @@ -20,20 +20,10 @@ class SNBOutput(OutputFormatPlugin): file_type = 'snb' options = set([ - # OptionRecommendation(name='newline', recommended_value='system', - # level=OptionRecommendation.LOW, - # short_switch='n', choices=TxtNewlines.NEWLINE_TYPES.keys(), - # help=_('Type of newline to use. Options are %s. Default is \'system\'. ' - # 'Use \'old_mac\' for compatibility with Mac OS 9 and earlier. ' - # 'For Mac OS X use \'unix\'. \'system\' will default to the newline ' - # 'type used by this OS.') % sorted(TxtNewlines.NEWLINE_TYPES.keys())), OptionRecommendation(name='snb_output_encoding', recommended_value='utf-8', level=OptionRecommendation.LOW, help=_('Specify the character encoding of the output document. ' \ 'The default is utf-8.')), - # OptionRecommendation(name='inline_toc', - # recommended_value=False, level=OptionRecommendation.LOW, - # help=_('Add Table of Contents to beginning of the book.')), OptionRecommendation(name='snb_max_line_length', recommended_value=0, level=OptionRecommendation.LOW, help=_('The maximum number of characters per line. This splits on ' @@ -41,10 +31,18 @@ class SNBOutput(OutputFormatPlugin): 'the line will be broken at the space after and will exceed the ' 'specified value. Also, there is a minimum of 25 characters. ' 'Use 0 to disable line splitting.')), - # OptionRecommendation(name='force_max_line_length', - # recommended_value=False, level=OptionRecommendation.LOW, - # help=_('Force splitting on the max-line-length value when no space ' - # 'is present. Also allows max-line-length to be below the minimum')), + OptionRecommendation(name='snb_insert_empty_line', + recommended_value=False, level=OptionRecommendation.LOW, + help=_('Specify whether or not to insert an empty line between ' + 'two paragraphs.')), + OptionRecommendation(name='snb_indent_first_line', + recommended_value=True, level=OptionRecommendation.LOW, + help=_('Specify whether or not to insert two space characters ' + 'to indent the first line of each paragraph.')), + OptionRecommendation(name='snb_hide_chapter_name', + recommended_value=False, level=OptionRecommendation.LOW, + help=_('Specify whether or not to hide the chapter title for each ' + 'chapter. Useful for image-only output (eg. comics).')), ]) def convert(self, oeb_book, output_path, input_plugin, opts, log): @@ -230,7 +228,7 @@ class SNBOutput(OutputFormatPlugin): img.load(imageData) (x,y) = img.size if self.opts: - SCREEN_Y, SCREEN_X = self.opts.output_profile.comic_screen_size + SCREEN_X, SCREEN_Y = self.opts.output_profile.comic_screen_size else: SCREEN_X = 540 SCREEN_Y = 700 diff --git a/src/calibre/ebooks/snb/snbml.py b/src/calibre/ebooks/snb/snbml.py index e3eed5a476..d910b6751d 100644 --- a/src/calibre/ebooks/snb/snbml.py +++ b/src/calibre/ebooks/snb/snbml.py @@ -88,7 +88,10 @@ class SNBMLizer(object): trees = { } for subitem, subtitle in self.subitems: snbcTree = etree.Element("snbc") - etree.SubElement(etree.SubElement(snbcTree, "head"), "title").text = subtitle + snbcHead = etree.SubElement(snbcTree, "head") + etree.SubElement(snbcHead, "title").text = subtitle + if self.opts and self.opts.snb_hide_chapter_name: + etree.SubElement(snbcHead, "hidetitle").text = u"true" etree.SubElement(snbcTree, "body") trees[subitem] = snbcTree output.append(u'%s%s\n\n' % (CALIBRE_SNB_BM_TAG, "")) @@ -96,27 +99,37 @@ class SNBMLizer(object): output = self.cleanup_text(u''.join(output)) subitem = '' + bodyTree = trees[subitem].find(".//body") for line in output.splitlines(): if not line.find(CALIBRE_SNB_PRE_TAG) == 0: line = line.strip(u' \t\n\r\u3000') else: - etree.SubElement(trees[subitem].find(".//body"), "text").text = \ + etree.SubElement(bodyTree, "text").text = \ etree.CDATA(line[len(CALIBRE_SNB_PRE_TAG):]) continue if len(line) != 0: if line.find(CALIBRE_SNB_IMG_TAG) == 0: prefix = ProcessFileName(os.path.dirname(self.item.href)) if prefix != '': - etree.SubElement(trees[subitem].find(".//body"), "img").text = \ + etree.SubElement(bodyTree, "img").text = \ prefix + '_' + line[len(CALIBRE_SNB_IMG_TAG):] else: - etree.SubElement(trees[subitem].find(".//body"), "img").text = \ + etree.SubElement(bodyTree, "img").text = \ line[len(CALIBRE_SNB_IMG_TAG):] elif line.find(CALIBRE_SNB_BM_TAG) == 0: subitem = line[len(CALIBRE_SNB_BM_TAG):] + bodyTree = trees[subitem].find(".//body") else: - etree.SubElement(trees[subitem].find(".//body"), "text").text = \ - etree.CDATA(unicode(u'\u3000\u3000' + line)) + if self.opts and self.opts.snb_indent_first_line: + prefix = u'\u3000\u3000' + else: + prefix = u'' + etree.SubElement(bodyTree, "text").text = \ + etree.CDATA(unicode(prefix + line)) + if self.opts and self.opts.snb_insert_empty_line: + etree.SubElement(bodyTree, "text").text = \ + etree.CDATA(u'') + return trees def remove_newlines(self, text): diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index 851b94f3a4..4820bd251c 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -399,6 +399,7 @@ class FileIconProvider(QFileIconProvider): 'fb2' : 'fb2', 'rtf' : 'rtf', 'odt' : 'odt', + 'snb' : 'snb', } def __init__(self): diff --git a/src/calibre/gui2/convert/snb_output.py b/src/calibre/gui2/convert/snb_output.py index b3ebfc747f..e3a6861811 100644 --- a/src/calibre/gui2/convert/snb_output.py +++ b/src/calibre/gui2/convert/snb_output.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- __license__ = 'GPL 3' -__copyright__ = '2009, John Schember ' +__copyright__ = '2010, Li Fanxi ' __docformat__ = 'restructuredtext en' from calibre.gui2.convert.snb_output_ui import Ui_Form @@ -18,18 +18,9 @@ class PluginWidget(Widget, Ui_Form): def __init__(self, parent, get_option, get_help, db=None, book_id=None): Widget.__init__(self, parent, - []) + ['snb_insert_empty_line', 'snb_indent_first_line', + 'snb_hide_chapter_name',]) self.db, self.book_id = db, book_id self.initialize_options(get_option, get_help, db, book_id) - # default = self.opt_newline.currentText() - # global newline_model - # if newline_model is None: - # newline_model = BasicComboModel(TxtNewlines.NEWLINE_TYPES.keys()) - # self.newline_model = newline_model - # self.opt_newline.setModel(self.newline_model) - - # default_index = self.opt_newline.findText(default) - # system_index = self.opt_newline.findText('system') - # self.opt_newline.setCurrentIndex(default_index if default_index != -1 else system_index if system_index != -1 else 0) diff --git a/src/calibre/gui2/convert/snb_output.ui b/src/calibre/gui2/convert/snb_output.ui index a5ff8ce7ef..0decd7469d 100644 --- a/src/calibre/gui2/convert/snb_output.ui +++ b/src/calibre/gui2/convert/snb_output.ui @@ -13,60 +13,41 @@ Form - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Hide chapter name + + + + + + + Insert space before the first line for each paragraph + + + + + + + Insert empty line between paragraphs + + + diff --git a/src/calibre/gui2/wizard/__init__.py b/src/calibre/gui2/wizard/__init__.py index 37b7c7bd7c..54d034a705 100644 --- a/src/calibre/gui2/wizard/__init__.py +++ b/src/calibre/gui2/wizard/__init__.py @@ -219,6 +219,13 @@ class EZReaderPP(HanlinV5): manufacturer = 'Astak' id = 'ezreader_pp' +class Bambook(Device): + + name = 'Sanda Bambook' + output_format = 'SNB' + manufacturer = 'Sanda' + id = 'bambook' + output_profile = 'bambook' # }}} def get_devices():