From 757d9a533f9cc0e54dd3b701817cfae6600f3251 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 20 Jan 2009 10:12:48 -0800 Subject: [PATCH] EPUB Output:Remove object and embed tags when using profile PRS505 as they cause the reader to crash --- src/calibre/ebooks/epub/__init__.py | 10 ++++++---- src/calibre/ebooks/epub/from_html.py | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/epub/__init__.py b/src/calibre/ebooks/epub/__init__.py index 442f5260b1..4e305b000b 100644 --- a/src/calibre/ebooks/epub/__init__.py +++ b/src/calibre/ebooks/epub/__init__.py @@ -15,15 +15,17 @@ from lxml import etree class DefaultProfile(object): - flow_size = sys.maxint - screen_size = None + flow_size = sys.maxint + screen_size = None remove_special_chars = False + remove_object_tags = False class PRS505(DefaultProfile): - flow_size = 270000 - screen_size = (590, 765) + flow_size = 270000 + screen_size = (590, 765) remove_special_chars = re.compile(u'[\u200b\u00ad]') + remove_object_tags = True PROFILES = { diff --git a/src/calibre/ebooks/epub/from_html.py b/src/calibre/ebooks/epub/from_html.py index 179c0af22b..664ac21de9 100644 --- a/src/calibre/ebooks/epub/from_html.py +++ b/src/calibre/ebooks/epub/from_html.py @@ -158,6 +158,10 @@ class HTMLProcessor(Processor, Rationalizer): for br in self.body.xpath('./br'): br.tag = 'p' br.text = u'\u00a0' + + if self.opts.profile.remove_object_tags: + for tag in self.root.xpath('//object|//embed'): + tag.getparent().remove(tag) def save(self): for meta in list(self.root.xpath('//meta')):