From aad985ad06f24e9c04054a55f87a21d2369af7f5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 26 Aug 2013 15:30:44 +0530 Subject: [PATCH] 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. --- src/calibre/ebooks/metadata/opf2.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/metadata/opf2.py b/src/calibre/ebooks/metadata/opf2.py index 52b8238a8f..d0e04b72a3 100644 --- a/src/calibre/ebooks/metadata/opf2.py +++ b/src/calibre/ebooks/metadata/opf2.py @@ -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))