This commit is contained in:
Kovid Goyal 2018-05-31 11:48:40 +05:30
parent b1101b7693
commit 5048ecbf84
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -133,8 +133,7 @@ class Stylizer(object):
log=logging.getLogger('calibre.css')) log=logging.getLogger('calibre.css'))
self.font_face_rules = [] self.font_face_rules = []
for elem in style_tags: for elem in style_tags:
if (elem.tag == XHTML('style') and if (elem.tag == XHTML('style') and elem.get('type', CSS_MIME) in OEB_STYLES and media_ok(elem.get('media'))):
elem.get('type', CSS_MIME) in OEB_STYLES and media_ok(elem.get('media'))):
text = elem.text if elem.text else u'' text = elem.text if elem.text else u''
for x in elem: for x in elem:
t = getattr(x, 'text', None) t = getattr(x, 'text', None)
@ -171,11 +170,10 @@ class Stylizer(object):
replaceUrls(stylesheet, item.abshref, replaceUrls(stylesheet, item.abshref,
ignoreImportRules=True) ignoreImportRules=True)
stylesheets.append(stylesheet) stylesheets.append(stylesheet)
elif (elem.tag == XHTML('link') and elem.get('href') and elif (elem.tag == XHTML('link') and elem.get('href') and elem.get(
elem.get('rel', 'stylesheet').lower() == 'stylesheet' and 'rel', 'stylesheet').lower() == 'stylesheet' and elem.get(
elem.get('type', CSS_MIME).lower() in OEB_STYLES and 'type', CSS_MIME).lower() in OEB_STYLES and media_ok(elem.get('media'))
media_ok(elem.get('media')) ):
):
href = urlnormalize(elem.attrib['href']) href = urlnormalize(elem.attrib['href'])
path = item.abshref(href) path = item.abshref(href)
sitem = oeb.manifest.hrefs.get(path, None) sitem = oeb.manifest.hrefs.get(path, None)