mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
48f0079d06
commit
799f818e7d
@ -716,6 +716,7 @@ class MobiReader(object):
|
|||||||
ent_pat = re.compile(r'&(\S+?);')
|
ent_pat = re.compile(r'&(\S+?);')
|
||||||
if elems:
|
if elems:
|
||||||
tocobj = TOC()
|
tocobj = TOC()
|
||||||
|
found = False
|
||||||
reached = False
|
reached = False
|
||||||
for x in root.iter():
|
for x in root.iter():
|
||||||
if x == elems[-1]:
|
if x == elems[-1]:
|
||||||
@ -732,7 +733,8 @@ class MobiReader(object):
|
|||||||
text = ent_pat.sub(entity_to_unicode, text)
|
text = ent_pat.sub(entity_to_unicode, text)
|
||||||
tocobj.add_item(toc.partition('#')[0], href[1:],
|
tocobj.add_item(toc.partition('#')[0], href[1:],
|
||||||
text)
|
text)
|
||||||
if reached and x.get('class', None) == 'mbp_pagebreak':
|
found = True
|
||||||
|
if reached and found and x.get('class', None) == 'mbp_pagebreak':
|
||||||
break
|
break
|
||||||
if tocobj is not None:
|
if tocobj is not None:
|
||||||
opf.set_toc(tocobj)
|
opf.set_toc(tocobj)
|
||||||
|
@ -426,7 +426,7 @@ def do_show_metadata(db, id, as_opf):
|
|||||||
mi = OPFCreator(os.getcwd(), mi)
|
mi = OPFCreator(os.getcwd(), mi)
|
||||||
mi.render(sys.stdout)
|
mi.render(sys.stdout)
|
||||||
else:
|
else:
|
||||||
print unicode(mi).encode(preferred_encoding)
|
prints(unicode(mi))
|
||||||
|
|
||||||
def show_metadata_option_parser():
|
def show_metadata_option_parser():
|
||||||
parser = get_parser(_(
|
parser = get_parser(_(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user