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

This commit is contained in:
Kovid Goyal 2010-10-01 10:50:07 -06:00
parent 5471913bba
commit 74a691134f
3 changed files with 9 additions and 3 deletions

View File

@ -255,6 +255,9 @@ class OutputProfile(Plugin):
#: Unsupported unicode characters to be replaced during preprocessing #: Unsupported unicode characters to be replaced during preprocessing
unsupported_unicode_chars = [] unsupported_unicode_chars = []
#: Number of ems that the left margin of a blockquote is rendered as
mobi_ems_per_blockquote = 1.0
@classmethod @classmethod
def tags_to_string(cls, tags): def tags_to_string(cls, tags):
return escape(', '.join(tags)) return escape(', '.join(tags))
@ -564,6 +567,7 @@ class KindleOutput(OutputProfile):
supports_mobi_indexing = True supports_mobi_indexing = True
periodical_date_in_title = False periodical_date_in_title = False
ratings_char = u'\u2605' ratings_char = u'\u2605'
mobi_ems_per_blockquote = 2.0
@classmethod @classmethod
def tags_to_string(cls, tags): def tags_to_string(cls, tags):
@ -582,6 +586,7 @@ class KindleDXOutput(OutputProfile):
comic_screen_size = (741, 1022) comic_screen_size = (741, 1022)
supports_mobi_indexing = True supports_mobi_indexing = True
periodical_date_in_title = False periodical_date_in_title = False
mobi_ems_per_blockquote = 2.0
@classmethod @classmethod
def tags_to_string(cls, tags): def tags_to_string(cls, tags):

View File

@ -184,13 +184,14 @@ class MobiMLizer(object):
elif tag in NESTABLE_TAGS and istate.rendered: elif tag in NESTABLE_TAGS and istate.rendered:
para = wrapper = bstate.nested[-1] para = wrapper = bstate.nested[-1]
elif left > 0 and indent >= 0: elif left > 0 and indent >= 0:
ems = self.profile.mobi_ems_per_blockquote
para = wrapper = etree.SubElement(parent, XHTML('blockquote')) para = wrapper = etree.SubElement(parent, XHTML('blockquote'))
para = wrapper para = wrapper
emleft = int(round(left / self.profile.fbase)) - 1 emleft = int(round(left / self.profile.fbase)) - ems
emleft = min((emleft, 10)) emleft = min((emleft, 10))
while emleft > 0: while emleft > 0:
para = etree.SubElement(para, XHTML('blockquote')) para = etree.SubElement(para, XHTML('blockquote'))
emleft -= 1 emleft -= ems
else: else:
para = wrapper = etree.SubElement(parent, XHTML('p')) para = wrapper = etree.SubElement(parent, XHTML('p'))
bstate.inline = bstate.para = para bstate.inline = bstate.para = para

View File

@ -234,7 +234,7 @@ class MobiReader(object):
self.debug = debug self.debug = debug
self.embedded_mi = None self.embedded_mi = None
self.base_css_rules = textwrap.dedent(''' 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 } p { margin: 0em; text-align: justify }