From fc246ebdd54ddb338a644d304a3113c081bcaf0b Mon Sep 17 00:00:00 2001 From: "Marshall T. Vandegrift" Date: Wed, 14 Jan 2009 17:44:49 -0500 Subject: [PATCH] Don't trim references, as they may *not* be spine items. --- src/calibre/ebooks/oeb/transforms/trimmanifest.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/transforms/trimmanifest.py b/src/calibre/ebooks/oeb/transforms/trimmanifest.py index b65116d16b..bd2c388245 100644 --- a/src/calibre/ebooks/oeb/transforms/trimmanifest.py +++ b/src/calibre/ebooks/oeb/transforms/trimmanifest.py @@ -9,6 +9,7 @@ __copyright__ = '2008, Marshall T. Vandegrift ' import sys import os from itertools import chain +from urlparse import urldefrag from lxml import etree import cssutils from calibre.ebooks.oeb.base import XPNSMAP, CSS_MIME, OEB_DOCS @@ -29,6 +30,11 @@ class ManifestTrimmer(object): used.add(oeb.manifest.hrefs[item.value]) elif item.value in oeb.manifest.ids: used.add(oeb.manifest.ids[item.value]) + for ref in oeb.guide.values(): + path, _ = urldefrag(ref.href) + if path in oeb.manifest.hrefs: + used.add(oeb.manifest.hrefs[path]) + # TOC items are required to be in the spine for item in oeb.spine: used.add(item) unchecked = used @@ -56,7 +62,6 @@ class ManifestTrimmer(object): cssutils.replaceUrls(sheet, replacer) used.update(new) unchecked = new - # All guide and TOC items are required to be in the spine for item in oeb.manifest.values(): if item not in used: oeb.logger.info('Trimming %r from manifest' % item.href)