TXT Output: Do not fail when input contains HTML comments with double hyphens in the comment text.

This commit is contained in:
Kovid Goyal 2015-09-29 14:18:07 +05:30
parent e1c1e617bc
commit 156058f295

View File

@ -68,6 +68,9 @@ class TXTMLizer(object):
output.append(self.get_toc()) output.append(self.get_toc())
for item in self.oeb_book.spine: for item in self.oeb_book.spine:
self.log.debug('Converting %s to TXT...' % item.href) self.log.debug('Converting %s to TXT...' % item.href)
for x in item.data.iterdescendants(etree.Comment):
if x.text and '--' in x.text:
x.text = x.text.replace('--', '__')
content = unicode(etree.tostring(item.data, encoding=unicode)) content = unicode(etree.tostring(item.data, encoding=unicode))
content = self.remove_newlines(content) content = self.remove_newlines(content)
content = etree.fromstring(content) content = etree.fromstring(content)