mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB Input: Handle ncx files that have <navpoint> elements with no content correctly. Fixes #7396 (calibre does not show TOC from attached epub file)
This commit is contained in:
parent
219feadc1e
commit
908c0ce46e
@ -182,6 +182,7 @@ class TOC(list):
|
|||||||
except:
|
except:
|
||||||
play_order = 1
|
play_order = 1
|
||||||
href = fragment = text = None
|
href = fragment = text = None
|
||||||
|
nd = dest
|
||||||
nl = nl_path(np)
|
nl = nl_path(np)
|
||||||
if nl:
|
if nl:
|
||||||
nl = nl[0]
|
nl = nl[0]
|
||||||
@ -190,17 +191,14 @@ class TOC(list):
|
|||||||
text += etree.tostring(txt, method='text',
|
text += etree.tostring(txt, method='text',
|
||||||
encoding=unicode, with_tail=False)
|
encoding=unicode, with_tail=False)
|
||||||
content = content_path(np)
|
content = content_path(np)
|
||||||
if not content or not text:
|
if content and text:
|
||||||
return
|
content = content[0]
|
||||||
content = content[0]
|
src = get_attr(content, attr='src')
|
||||||
src = get_attr(content, attr='src')
|
if src:
|
||||||
if src is None:
|
purl = urlparse(unquote(content.get('src')))
|
||||||
return
|
href, fragment = purl[2], purl[5]
|
||||||
|
nd = dest.add_item(href, fragment, text)
|
||||||
purl = urlparse(unquote(content.get('src')))
|
nd.play_order = play_order
|
||||||
href, fragment = purl[2], purl[5]
|
|
||||||
nd = dest.add_item(href, fragment, text)
|
|
||||||
nd.play_order = play_order
|
|
||||||
|
|
||||||
for c in np_path(np):
|
for c in np_path(np):
|
||||||
process_navpoint(c, nd)
|
process_navpoint(c, nd)
|
||||||
|
@ -358,10 +358,11 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
|||||||
|
|
||||||
def toc_clicked(self, index):
|
def toc_clicked(self, index):
|
||||||
item = self.toc_model.itemFromIndex(index)
|
item = self.toc_model.itemFromIndex(index)
|
||||||
url = QUrl.fromLocalFile(item.abspath)
|
if item.abspath is not None:
|
||||||
if item.fragment:
|
url = QUrl.fromLocalFile(item.abspath)
|
||||||
url.setFragment(item.fragment)
|
if item.fragment:
|
||||||
self.link_clicked(url)
|
url.setFragment(item.fragment)
|
||||||
|
self.link_clicked(url)
|
||||||
|
|
||||||
def selection_changed(self, selected_text):
|
def selection_changed(self, selected_text):
|
||||||
self.selected_text = selected_text.strip()
|
self.selected_text = selected_text.strip()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user