MOBI Input: Fix conversion of MOBI files with malformed markup and embeded <guide> tags not working. Fixes #1836548 [Private bug](https://bugs.launchpad.net/calibre/+bug/1836548)

This commit is contained in:
Kovid Goyal 2019-07-15 22:34:20 +05:30
parent 8dc5c82fa0
commit 2a6e7ea82d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -197,6 +197,10 @@ class MobiReader(object):
from html5_parser import parse
self.log.warning('Malformed markup, parsing using html5-parser')
self.processed_html = strip_encoding_declarations(self.processed_html)
# These trip up the html5 parser causing all content to be placed
# under the <guide> tag
self.processed_html = re.sub(r'<metadata>.+?</metadata>', '', self.processed_html, flags=re.I)
self.processed_html = re.sub(r'<guide>.+?</guide>', '', self.processed_html, flags=re.I)
try:
root = parse(self.processed_html, maybe_xhtml=False, keep_doctype=False, sanitize_names=True)
except Exception: