From 200833412c0e8d98851350686807e7f69cbd8a07 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 29 Nov 2013 07:55:55 +0530 Subject: [PATCH] EPUB Output: Strip -- characters from inside comments, as some ebook reading apps cannot handle them. Fixes #1256059 [epub file not rendering in Android Mantano reader](https://bugs.launchpad.net/calibre/+bug/1256059) --- src/calibre/ebooks/oeb/base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/calibre/ebooks/oeb/base.py b/src/calibre/ebooks/oeb/base.py index 647c52c581..57b3165700 100644 --- a/src/calibre/ebooks/oeb/base.py +++ b/src/calibre/ebooks/oeb/base.py @@ -325,6 +325,11 @@ def xpath(elem, expr): return elem.xpath(expr, namespaces=XPNSMAP) def xml2str(root, pretty_print=False, strip_comments=False, with_tail=True): + if not strip_comments: + # -- in comments trips up adobe digital editions + for x in root.iterdescendants(etree.Comment): + if x.text and '--' in x.text: + x.text = x.text.replace('--', '__') ans = etree.tostring(root, encoding='utf-8', xml_declaration=True, pretty_print=pretty_print, with_tail=with_tail)