From 9e3156782d2df7a38b3b3b8c8474f90cfed4d297 Mon Sep 17 00:00:00 2001 From: "Marshall T. Vandegrift" Date: Sun, 28 Jun 2009 10:04:21 -0400 Subject: [PATCH] Cleaner fix for #2696. --- src/calibre/ebooks/lit/writer.py | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/calibre/ebooks/lit/writer.py b/src/calibre/ebooks/lit/writer.py index 943fa6db62..e0cc691ad1 100644 --- a/src/calibre/ebooks/lit/writer.py +++ b/src/calibre/ebooks/lit/writer.py @@ -161,7 +161,7 @@ class ReBinary(object): def tree_to_binary(self, elem, nsrmap=NSRMAP, parents=[], inhead=False, preserve=False): if not isinstance(elem.tag, basestring): - self.write(etree.tostring(elem)) + # Don't emit any comments or raw entities return nsrmap = copy.copy(nsrmap) attrib = dict(elem.attrib) @@ -308,31 +308,6 @@ class LitWriter(object): else: self._logger.warn('No suitable cover image found.') - # Remove comments because they are not supported by LIT HTML - for item in oeb.spine: - for elem in item.data.getiterator(): - if isinstance(elem, etree._Comment): - tail = elem.tail - parent = elem.getparent() - index = parent.index(elem) - text = u'' - if index == 0: - if parent.text: - text += parent.text - if tail: - text += tail - parent.text = text - else: - prev = parent[index-1] - text = u'' - if prev.tail: - text += prev.tail - if tail: - text += tail - prev.tail = text - parent.remove(elem) - - def __call__(self, oeb, path): if hasattr(path, 'write'): return self._dump_stream(oeb, path) @@ -734,5 +709,3 @@ class LitWriter(object): ichunk = ''.join(['AOLI', pack('