diff --git a/src/calibre/ebooks/mobi/reader.py b/src/calibre/ebooks/mobi/reader.py index 5010e9e8e8..ff398ca3bb 100644 --- a/src/calibre/ebooks/mobi/reader.py +++ b/src/calibre/ebooks/mobi/reader.py @@ -305,6 +305,15 @@ class MobiReader(object): self.log.warning('Markup contains unclosed

tags, parsing using', 'BeatifulSoup') root = soupparser.fromstring(self.processed_html) + if root[0].tag != 'html': + self.log.warn('File does not have opening tag') + nroot = html.fromstring('') + bod = nroot.find('body') + for child in list(root): + child.getparent().remove(child) + bod.append(child) + root = nroot + self.upshift_markup(root) guides = root.xpath('//guide') guide = guides[0] if guides else None