From bf3913b791eee8a3df0ed80148dbc4fb9511cffd Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 30 May 2012 19:32:47 +0530 Subject: [PATCH] EPUB Input: Do no skip the valid children of an NCX node that has no text/href --- src/calibre/ebooks/oeb/reader.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/oeb/reader.py b/src/calibre/ebooks/oeb/reader.py index 3531ca0250..e0bcc4147c 100644 --- a/src/calibre/ebooks/oeb/reader.py +++ b/src/calibre/ebooks/oeb/reader.py @@ -363,13 +363,24 @@ class OEBReader(object): title = ''.join(xpath(child, 'ncx:navLabel/ncx:text/text()')) title = COLLAPSE_RE.sub(' ', title.strip()) href = xpath(child, 'ncx:content/@src') - if not title or not href: + if not title: + self._toc_from_navpoint(item, toc, child) continue + if not href: + gc = xpath(child, 'ncx:navPoint') + if not gc: + # This node is useless + continue + href = 'missing.html' + href = item.abshref(urlnormalize(href[0])) path, _ = urldefrag(href) if path not in self.oeb.manifest.hrefs: self.logger.warn('TOC reference %r not found' % href) - continue + gc = xpath(child, 'ncx:navPoint') + if not gc: + # This node is useless + continue id = child.get('id') klass = child.get('class', 'chapter')