mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-04-27 20:13:12 +02:00
Fix a metadata error. Add parsing @import queries.
This commit is contained in:
parent
c6d7e31ea1
commit
04ebf1ec20
2 changed files with 6 additions and 4 deletions
|
|
@ -172,7 +172,7 @@ def __init__(self, oeb):
|
|||
|
||||
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 @@ def __init__(self, tree, path, oeb, page=Profiles.PRS505):
|
|||
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 @@ def __init__(self, tree, path, oeb, page=Profiles.PRS505):
|
|||
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…
Reference in a new issue