From 74a691134fbb024176dfab93212edb61283d22e2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Oct 2010 10:50:07 -0600 Subject: [PATCH] MOBI Output: Fix bug that could caused left margins in the MOBI file to have twice the size of the left margins in the input document --- src/calibre/customize/profiles.py | 5 +++++ src/calibre/ebooks/mobi/mobiml.py | 5 +++-- src/calibre/ebooks/mobi/reader.py | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/calibre/customize/profiles.py b/src/calibre/customize/profiles.py index 0310f09242..1d879f0c5d 100644 --- a/src/calibre/customize/profiles.py +++ b/src/calibre/customize/profiles.py @@ -255,6 +255,9 @@ class OutputProfile(Plugin): #: Unsupported unicode characters to be replaced during preprocessing unsupported_unicode_chars = [] + #: Number of ems that the left margin of a blockquote is rendered as + mobi_ems_per_blockquote = 1.0 + @classmethod def tags_to_string(cls, tags): return escape(', '.join(tags)) @@ -564,6 +567,7 @@ class KindleOutput(OutputProfile): supports_mobi_indexing = True periodical_date_in_title = False ratings_char = u'\u2605' + mobi_ems_per_blockquote = 2.0 @classmethod def tags_to_string(cls, tags): @@ -582,6 +586,7 @@ class KindleDXOutput(OutputProfile): comic_screen_size = (741, 1022) supports_mobi_indexing = True periodical_date_in_title = False + mobi_ems_per_blockquote = 2.0 @classmethod def tags_to_string(cls, tags): diff --git a/src/calibre/ebooks/mobi/mobiml.py b/src/calibre/ebooks/mobi/mobiml.py index 231ad51eee..a822e66758 100644 --- a/src/calibre/ebooks/mobi/mobiml.py +++ b/src/calibre/ebooks/mobi/mobiml.py @@ -184,13 +184,14 @@ class MobiMLizer(object): elif tag in NESTABLE_TAGS and istate.rendered: para = wrapper = bstate.nested[-1] elif left > 0 and indent >= 0: + ems = self.profile.mobi_ems_per_blockquote para = wrapper = etree.SubElement(parent, XHTML('blockquote')) para = wrapper - emleft = int(round(left / self.profile.fbase)) - 1 + emleft = int(round(left / self.profile.fbase)) - ems emleft = min((emleft, 10)) while emleft > 0: para = etree.SubElement(para, XHTML('blockquote')) - emleft -= 1 + emleft -= ems else: para = wrapper = etree.SubElement(parent, XHTML('p')) bstate.inline = bstate.para = para diff --git a/src/calibre/ebooks/mobi/reader.py b/src/calibre/ebooks/mobi/reader.py index 0cf31d64ec..dbe6854006 100644 --- a/src/calibre/ebooks/mobi/reader.py +++ b/src/calibre/ebooks/mobi/reader.py @@ -234,7 +234,7 @@ class MobiReader(object): self.debug = debug self.embedded_mi = None self.base_css_rules = textwrap.dedent(''' - blockquote { margin: 0em 0em 0em 1em; text-align: justify } + blockquote { margin: 0em 0em 0em 2em; text-align: justify } p { margin: 0em; text-align: justify }