MOBI Input: Fix detection of Table of Contents for MOBI files that have a page break between the location designated as the Table of Contents and the actual table of contents. Fixes #763504 (Private bug)

This commit is contained in:
Kovid Goyal 2011-04-17 08:14:00 -06:00
parent 48f0079d06
commit 799f818e7d
2 changed files with 4 additions and 2 deletions

View File

@ -716,6 +716,7 @@ class MobiReader(object):
ent_pat = re.compile(r'&(\S+?);')
if elems:
tocobj = TOC()
found = False
reached = False
for x in root.iter():
if x == elems[-1]:
@ -732,7 +733,8 @@ class MobiReader(object):
text = ent_pat.sub(entity_to_unicode, text)
tocobj.add_item(toc.partition('#')[0], href[1:],
text)
if reached and x.get('class', None) == 'mbp_pagebreak':
found = True
if reached and found and x.get('class', None) == 'mbp_pagebreak':
break
if tocobj is not None:
opf.set_toc(tocobj)

View File

@ -426,7 +426,7 @@ def do_show_metadata(db, id, as_opf):
mi = OPFCreator(os.getcwd(), mi)
mi.render(sys.stdout)
else:
print unicode(mi).encode(preferred_encoding)
prints(unicode(mi))
def show_metadata_option_parser():
parser = get_parser(_(