From 156058f295e5453a4a62db6c96fa467dea1e3288 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 29 Sep 2015 14:18:07 +0530 Subject: [PATCH] TXT Output: Do not fail when input contains HTML comments with double hyphens in the comment text. --- src/calibre/ebooks/txt/txtml.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/calibre/ebooks/txt/txtml.py b/src/calibre/ebooks/txt/txtml.py index 155d21d77d..9d19679962 100644 --- a/src/calibre/ebooks/txt/txtml.py +++ b/src/calibre/ebooks/txt/txtml.py @@ -68,6 +68,9 @@ class TXTMLizer(object): output.append(self.get_toc()) for item in self.oeb_book.spine: 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 = self.remove_newlines(content) content = etree.fromstring(content)