Edit Book: Fix an error caused by a landmark entry in EPUB 3 files that has an <a> tag without an href attribute.

This commit is contained in:
Kovid Goyal 2018-05-01 14:49:18 +05:30
parent 499578beaa
commit b1ee6be746
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -310,12 +310,13 @@ def get_nav_landmarks(container):
for li in elem.iterdescendants(XHTML('li')):
for a in li.iterdescendants(XHTML('a')):
href, rtype = a.get('href'), a.get(et)
title = etree.tostring(a, method='text', encoding=unicode, with_tail=False).strip()
href, frag = href.partition('#')[::2]
name = container.href_to_name(href, nav)
if container.has_name(name):
yield {'dest':name, 'frag':frag, 'title':title or '', 'type':rtype or ''}
break
if href:
title = etree.tostring(a, method='text', encoding=unicode, with_tail=False).strip()
href, frag = href.partition('#')[::2]
name = container.href_to_name(href, nav)
if container.has_name(name):
yield {'dest':name, 'frag':frag, 'title':title or '', 'type':rtype or ''}
break
def get_landmarks(container):