mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
MOBI Input: Fix regression in CSS handling
This commit is contained in:
parent
3f14ce65e7
commit
d2b7078adb
@ -340,6 +340,13 @@ class MobiReader(object):
|
|||||||
'href':'styles.css'})
|
'href':'styles.css'})
|
||||||
head.insert(0, link)
|
head.insert(0, link)
|
||||||
link.tail = '\n\t'
|
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)
|
self.upshift_markup(root)
|
||||||
guides = root.xpath('//guide')
|
guides = root.xpath('//guide')
|
||||||
@ -460,7 +467,11 @@ class MobiReader(object):
|
|||||||
if attrib.has_key('align'):
|
if attrib.has_key('align'):
|
||||||
align = attrib.pop('align').strip()
|
align = attrib.pop('align').strip()
|
||||||
if align:
|
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 tag.tag == 'hr':
|
||||||
if mobi_version == 1:
|
if mobi_version == 1:
|
||||||
tag.tag = 'div'
|
tag.tag = 'div'
|
||||||
@ -501,13 +512,13 @@ class MobiReader(object):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
if styles:
|
if styles:
|
||||||
cls = None
|
ncls = None
|
||||||
rule = '; '.join(styles)
|
rule = '; '.join(styles)
|
||||||
for sel, srule in self.tag_css_rules.items():
|
for sel, srule in self.tag_css_rules.items():
|
||||||
if srule == rule:
|
if srule == rule:
|
||||||
cls = sel
|
ncls = sel
|
||||||
break
|
break
|
||||||
if cls is None:
|
if ncls is None:
|
||||||
ncls = 'calibre_%d' % i
|
ncls = 'calibre_%d' % i
|
||||||
self.tag_css_rules[ncls] = rule
|
self.tag_css_rules[ncls] = rule
|
||||||
cls = attrib.get('class', '')
|
cls = attrib.get('class', '')
|
||||||
|
@ -172,4 +172,3 @@ class DetectStructure(object):
|
|||||||
level2.add(text, _href,
|
level2.add(text, _href,
|
||||||
play_order=self.oeb.toc.next_play_order())
|
play_order=self.oeb.toc.next_play_order())
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user