Do not delete titles in EPUB 3

In EPUB 3 titles are not titles they can be series or sub titles or
hobgoblins and we have no well defined way to find out what they are, so
just replace the first title and call it quits.
This commit is contained in:
Kovid Goyal 2013-08-26 15:30:44 +05:30
parent 8a1f46a389
commit aad985ad06

View File

@ -793,11 +793,13 @@ class OPF(object): # {{{
def fset(self, val):
val = (val or '').strip()
titles = self.title_path(self.metadata)
if not val or self.package_version < 3:
if self.package_version < 3:
# EPUB 3 allows multiple title elements containing sub-titles,
# series and other things. We all loooove EPUB 3.
for title in titles:
title.getparent().remove(title)
titles = ()
if val:
titles = self.title_path(self.metadata)
title = titles[0] if titles else self.create_metadata_element('title')
title.text = re.sub(r'\s+', ' ', unicode(val))