EPUB Output:Remove object and embed tags when using profile PRS505 as they cause the reader to crash

This commit is contained in:
Kovid Goyal 2009-01-20 10:12:48 -08:00
parent e10146e56d
commit 757d9a533f
2 changed files with 10 additions and 4 deletions

View File

@ -18,12 +18,14 @@ class DefaultProfile(object):
flow_size = sys.maxint flow_size = sys.maxint
screen_size = None screen_size = None
remove_special_chars = False remove_special_chars = False
remove_object_tags = False
class PRS505(DefaultProfile): class PRS505(DefaultProfile):
flow_size = 270000 flow_size = 270000
screen_size = (590, 765) screen_size = (590, 765)
remove_special_chars = re.compile(u'[\u200b\u00ad]') remove_special_chars = re.compile(u'[\u200b\u00ad]')
remove_object_tags = True
PROFILES = { PROFILES = {

View File

@ -159,6 +159,10 @@ class HTMLProcessor(Processor, Rationalizer):
br.tag = 'p' br.tag = 'p'
br.text = u'\u00a0' 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): def save(self):
for meta in list(self.root.xpath('//meta')): for meta in list(self.root.xpath('//meta')):
meta.getparent().remove(meta) meta.getparent().remove(meta)