MOBI Input: Fix regression in CSS handling

This commit is contained in:
Kovid Goyal 2009-05-31 13:11:16 -07:00
parent 3f14ce65e7
commit d2b7078adb
2 changed files with 15 additions and 5 deletions

View File

@ -340,6 +340,13 @@ class MobiReader(object):
'href':'styles.css'})
head.insert(0, link)
link.tail = '\n\t'
title = head.xpath('descendant::title')
if not title:
title = head.makeelement('title', {})
title.text = self.book_header.title
title.tail = '\n\t'
head.insert(0, title)
head.text = '\n\t'
self.upshift_markup(root)
guides = root.xpath('//guide')
@ -460,7 +467,11 @@ class MobiReader(object):
if attrib.has_key('align'):
align = attrib.pop('align').strip()
if align:
styles.append('text-align: %s' % align)
align = align.lower()
if align == 'baseline':
styles.append('vertical-align: '+align)
else:
styles.append('text-align: %s' % align)
if tag.tag == 'hr':
if mobi_version == 1:
tag.tag = 'div'
@ -501,13 +512,13 @@ class MobiReader(object):
except ValueError:
pass
if styles:
cls = None
ncls = None
rule = '; '.join(styles)
for sel, srule in self.tag_css_rules.items():
if srule == rule:
cls = sel
ncls = sel
break
if cls is None:
if ncls is None:
ncls = 'calibre_%d' % i
self.tag_css_rules[ncls] = rule
cls = attrib.get('class', '')

View File

@ -172,4 +172,3 @@ class DetectStructure(object):
level2.add(text, _href,
play_order=self.oeb.toc.next_play_order())