Fix regression in 0.8.18 that broke viewing/converting of some MOBI files. Fixes #846216 (Could not open ebook)

This commit is contained in:
Kovid Goyal 2011-09-09 23:00:53 -06:00
parent 9e54a069bb
commit cce0b15293

View File

@ -654,8 +654,9 @@ class MobiReader(object):
pass pass
if (tag.tag == 'a' and attrib.get('id', '').startswith('filepos') if (tag.tag == 'a' and attrib.get('id', '').startswith('filepos')
and not tag.text and (tag.tail is None or not and not tag.text and (tag.tail is None or not
tag.tail.strip()) and tag.getnext().tag in ('h1', 'h2', tag.tail.strip()) and getattr(tag.getnext(), 'tag',
'h3', 'h4', 'h5', 'h6', 'div', 'p')): None) in ('h1', 'h2', 'h3', 'h4', 'h5', 'h6',
'div', 'p')):
# This is an empty anchor immediately before a block tag, move # This is an empty anchor immediately before a block tag, move
# the id onto the block tag instead # the id onto the block tag instead
forwardable_anchors.append(tag) forwardable_anchors.append(tag)