diff --git a/src/calibre/ebooks/mobi/reader/mobi6.py b/src/calibre/ebooks/mobi/reader/mobi6.py index 27f2cdaf8b..24962fc858 100644 --- a/src/calibre/ebooks/mobi/reader/mobi6.py +++ b/src/calibre/ebooks/mobi/reader/mobi6.py @@ -524,8 +524,8 @@ class MobiReader(object): attrib['href'] = "#filepos%d" % int(filepos) except ValueError: pass - if (tag.tag == 'a' and attrib.get('id', '').startswith('filepos') - and not tag.text and len(tag) == 0 and (tag.tail is None or not + if (tag.tag == 'a' and attrib.get('id', '').startswith('filepos') and + not tag.text and len(tag) == 0 and (tag.tail is None or not tag.tail.strip()) and getattr(tag.getnext(), 'tag', None) in BLOCK_TAGS): # This is an empty anchor immediately before a block tag, move