diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index d90e3bdfa4..43e951354f 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -942,7 +942,12 @@ class Manifest(object): if isinstance(data, etree._Element): ans = xml2str(data, pretty_print=self.oeb.pretty_print) if self.media_type in OEB_DOCS: - ans = re.sub(r'<(div|a|span)([^>]*)/>', r'<\1\2>', ans) + # Convert self closing div|span|a tags to normally closed + # ones, as they are interpreted incorrectly by some browser + # based renderers + ans = re.sub( + r'<(?Pdiv|a|span)(?=[\s/])(?P[^>]*)/\s*>', + r'<\g\g>>', ans) return ans if isinstance(data, unicode): return data.encode('utf-8')