Fix a few directory relativity bugs.

This commit is contained in:
Marshall T. Vandegrift 2009-01-09 22:52:21 -05:00
parent c4299cd17a
commit 56a64e1540
3 changed files with 13 additions and 10 deletions

View File

@ -186,10 +186,12 @@ class Serializer(object):
if attr == 'href':
if self.serialize_href(val, item):
continue
elif attr == 'src' and val in hrefs:
index = self.images[val]
buffer.write('recindex="%05d"' % index)
continue
elif attr == 'src':
href = item.abshref(val)
if href in hrefs:
index = self.images[href]
buffer.write('recindex="%05d"' % index)
continue
buffer.write(attr)
buffer.write('="')
self.serialize_text(val, quot=True)

View File

@ -914,11 +914,11 @@ class OEBBook(object):
cover = self.manifest.hrefs[href]
elif xpath(html, '//h:img[position()=1]'):
img = xpath(html, '//h:img[position()=1]')[0]
href = img.get('src')
href = spine0.abshref(img.get('src'))
cover = self.manifest.hrefs[href]
elif xpath(html, '//h:object[position()=1]'):
object = xpath(html, '//h:object[position()=1]')[0]
href = object.get('data')
href = spine0.abshref(object.get('data'))
cover = self.manifest.hrefs[href]
elif xpath(html, '//svg:svg[position()=1]'):
svg = copy.deepcopy(xpath(html, '//svg:svg[position()=1]')[0])

View File

@ -218,7 +218,9 @@ class CSSFlattener(object):
for child in node:
self.flatten_node(child, stylizer, names, styles, psize, left)
def flatten_head(self, head, stylizer, href):
def flatten_head(self, item, stylizer, href):
html = item.data
head = html.find(XHTML('head'))
for node in head:
if node.tag == XHTML('link') \
and node.get('rel', 'stylesheet') == 'stylesheet' \
@ -227,6 +229,7 @@ class CSSFlattener(object):
elif node.tag == XHTML('style') \
and node.get('type', CSS_MIME) in OEB_STYLES:
head.remove(node)
href = item.relhref(href)
etree.SubElement(head, XHTML('link'),
rel='stylesheet', type=CSS_MIME, href=href)
if stylizer.page_rule:
@ -259,7 +262,5 @@ class CSSFlattener(object):
css = ''.join(".%s {\n%s;\n}\n\n" % (key, val) for key, val in items)
href = self.replace_css(css)
for item in self.oeb.spine:
html = item.data
stylizer = self.stylizers[item]
head = html.find(XHTML('head'))
self.flatten_head(head, stylizer, href)
self.flatten_head(item, stylizer, href)