mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB Input: Fix styles in existing titlepage not being flattened when the titlepage is preserved during conversion. Fixes #1720715 [Use cover from source file can cause incorrect stylesheet linkage](https://bugs.launchpad.net/calibre/+bug/1720715)
This commit is contained in:
parent
db9e1a33f5
commit
ff05a6a5fe
@ -1461,6 +1461,9 @@ class Guide(object):
|
||||
def __getitem__(self, key):
|
||||
return self.refs[key]
|
||||
|
||||
def get(self, key):
|
||||
return self.refs.get(key)
|
||||
|
||||
def __delitem__(self, key):
|
||||
del self.refs[key]
|
||||
|
||||
|
@ -171,8 +171,14 @@ class CSSFlattener(object):
|
||||
|
||||
def __call__(self, oeb, context):
|
||||
oeb.logger.info('Flattening CSS and remapping font sizes...')
|
||||
self.context = self.opts =context
|
||||
self.context = self.opts = context
|
||||
self.oeb = oeb
|
||||
self.items = list(self.oeb.spine)
|
||||
titlepage = self.oeb.guide.get('titlepage')
|
||||
if titlepage is not None:
|
||||
titlepage = titlepage.item
|
||||
if titlepage is not None and titlepage not in self.items:
|
||||
self.items.append(titlepage)
|
||||
|
||||
self.filter_css = frozenset()
|
||||
if self.opts.filter_css:
|
||||
@ -260,7 +266,7 @@ class CSSFlattener(object):
|
||||
self.stylizers = {}
|
||||
profile = self.context.source
|
||||
css = ''
|
||||
for item in self.oeb.spine:
|
||||
for item in self.items:
|
||||
html = item.data
|
||||
body = html.find(XHTML('body'))
|
||||
if 'style' in html.attrib:
|
||||
@ -300,7 +306,7 @@ class CSSFlattener(object):
|
||||
|
||||
def baseline_spine(self):
|
||||
sizes = defaultdict(float)
|
||||
for item in self.oeb.spine:
|
||||
for item in self.items:
|
||||
html = item.data
|
||||
stylizer = self.stylizers[item]
|
||||
body = html.find(XHTML('body'))
|
||||
@ -595,7 +601,7 @@ class CSSFlattener(object):
|
||||
|
||||
def collect_global_css(self):
|
||||
global_css = defaultdict(list)
|
||||
for item in self.oeb.spine:
|
||||
for item in self.items:
|
||||
stylizer = self.stylizers[item]
|
||||
if float(self.context.margin_top) >= 0:
|
||||
stylizer.page_rule['margin-top'] = '%gpt'%\
|
||||
@ -634,7 +640,7 @@ class CSSFlattener(object):
|
||||
def flatten_spine(self):
|
||||
names = defaultdict(int)
|
||||
styles, pseudo_styles = {}, defaultdict(dict)
|
||||
for item in self.oeb.spine:
|
||||
for item in self.items:
|
||||
html = item.data
|
||||
stylizer = self.stylizers[item]
|
||||
if self.specializer is not None:
|
||||
@ -657,6 +663,6 @@ class CSSFlattener(object):
|
||||
|
||||
href = self.replace_css(css)
|
||||
global_css = self.collect_global_css()
|
||||
for item in self.oeb.spine:
|
||||
for item in self.items:
|
||||
stylizer = self.stylizers[item]
|
||||
self.flatten_head(item, href, global_css[item])
|
||||
|
Loading…
x
Reference in New Issue
Block a user