Cleaner fix for #2696.

This commit is contained in:
Marshall T. Vandegrift 2009-06-28 10:04:21 -04:00
parent aa54195d62
commit 9e3156782d

View File

@ -161,7 +161,7 @@ class ReBinary(object):
def tree_to_binary(self, elem, nsrmap=NSRMAP, parents=[], def tree_to_binary(self, elem, nsrmap=NSRMAP, parents=[],
inhead=False, preserve=False): inhead=False, preserve=False):
if not isinstance(elem.tag, basestring): if not isinstance(elem.tag, basestring):
self.write(etree.tostring(elem)) # Don't emit any comments or raw entities
return return
nsrmap = copy.copy(nsrmap) nsrmap = copy.copy(nsrmap)
attrib = dict(elem.attrib) attrib = dict(elem.attrib)
@ -308,31 +308,6 @@ class LitWriter(object):
else: else:
self._logger.warn('No suitable cover image found.') 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): def __call__(self, oeb, path):
if hasattr(path, 'write'): if hasattr(path, 'write'):
return self._dump_stream(oeb, path) return self._dump_stream(oeb, path)
@ -734,5 +709,3 @@ class LitWriter(object):
ichunk = ''.join(['AOLI', pack('<IQ', rem, len(dchunks)), ichunk = ''.join(['AOLI', pack('<IQ', rem, len(dchunks)),
ichunk.getvalue(), ('\0' * pad), pack('<H', len(dchunks))]) ichunk.getvalue(), ('\0' * pad), pack('<H', len(dchunks))])
return dcounts, dchunks, ichunk return dcounts, dchunks, ichunk