mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Fix #2177 (Google ePub TOC)
This commit is contained in:
parent
551e07031a
commit
11d33c0c8b
@ -508,6 +508,7 @@ class OPF(object):
|
||||
toc.partition('#')[0], toc.partition('#')[-1]
|
||||
self.toc.read_html_toc(toc)
|
||||
except:
|
||||
raise
|
||||
pass
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
import os, glob
|
||||
import os, glob, re
|
||||
from urlparse import urlparse
|
||||
from urllib import unquote
|
||||
|
||||
@ -151,12 +151,12 @@ class TOC(list):
|
||||
if play_order is None:
|
||||
play_order = int(np.get('playorder', 1))
|
||||
href = fragment = text = None
|
||||
nl = np.find('navlabel')
|
||||
nl = np.find(re.compile('navlabel'))
|
||||
if nl is not None:
|
||||
text = u''
|
||||
for txt in nl.findAll('text'):
|
||||
for txt in nl.findAll(re.compile('text')):
|
||||
text += ''.join([unicode(s) for s in txt.findAll(text=True)])
|
||||
content = np.find('content')
|
||||
content = np.find(re.compile('content'))
|
||||
if content is None or not content.has_key('src') or not txt:
|
||||
return
|
||||
|
||||
@ -166,15 +166,15 @@ class TOC(list):
|
||||
nd.play_order = play_order
|
||||
|
||||
for c in np:
|
||||
if getattr(c, 'name', None) == 'navpoint':
|
||||
if 'navpoint' in getattr(c, 'name', ''):
|
||||
process_navpoint(c, nd)
|
||||
|
||||
nm = soup.find('navmap')
|
||||
nm = soup.find(re.compile('navmap'))
|
||||
if nm is None:
|
||||
raise ValueError('NCX files must have a <navmap> element.')
|
||||
|
||||
for elem in nm:
|
||||
if getattr(elem, 'name', None) == 'navpoint':
|
||||
if 'navpoint' in getattr(elem, 'name', ''):
|
||||
process_navpoint(elem, self)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user