mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Fix a metadata error. Add parsing @import queries.
This commit is contained in:
parent
c6d7e31ea1
commit
04ebf1ec20
@ -172,7 +172,7 @@ class Metadata(object):
|
||||
|
||||
def add(self, term, value, attrib={}):
|
||||
item = self.Item(term, value, attrib)
|
||||
items = self.items[barename(term)]
|
||||
items = self.items[barename(item.term)]
|
||||
items.append(item)
|
||||
return item
|
||||
|
||||
|
@ -122,12 +122,14 @@ class Stylizer(object):
|
||||
basename = os.path.basename(path)
|
||||
cssname = os.path.splitext(basename)[0] + '.css'
|
||||
stylesheets = [HTML_CSS_STYLESHEET]
|
||||
head = xpath(tree, '/h:html/h:head')[0]
|
||||
head = xpath(tree, '/h:html/h:head')[0]
|
||||
parser = cssutils.CSSParser()
|
||||
parser.setFetcher(lambda path: ('utf-8', oeb.container.read(path)))
|
||||
for elem in head:
|
||||
tag = barename(elem.tag)
|
||||
if tag == 'style':
|
||||
text = ''.join(elem.text)
|
||||
stylesheet = cssutils.parseString(text, href=cssname)
|
||||
stylesheet = parser.parseString(text, href=cssname)
|
||||
stylesheets.append(stylesheet)
|
||||
elif tag == 'link' \
|
||||
and elem.get('rel', 'stylesheet') == 'stylesheet' \
|
||||
@ -140,7 +142,7 @@ class Stylizer(object):
|
||||
else:
|
||||
data = XHTML_CSS_NAMESPACE
|
||||
data += oeb.manifest.hrefs[path].data
|
||||
stylesheet = cssutils.parseString(data, href=path)
|
||||
stylesheet = parser.parseString(data, href=path)
|
||||
self.STYLESHEETS[path] = stylesheet
|
||||
stylesheets.append(stylesheet)
|
||||
rules = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user