From 14578688a7572cdf67928a61a45f2625ea5abf50 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 4 Oct 2015 18:24:23 +0530 Subject: [PATCH] HTMLZ Output: Set the HTML to the book title. Fixes #1502592 [HTMLZ output is missing the <title> tag](https://bugs.launchpad.net/calibre/+bug/1502592) --- src/calibre/ebooks/htmlz/oeb2html.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/htmlz/oeb2html.py b/src/calibre/ebooks/htmlz/oeb2html.py index a0bbc4af18..12a4271290 100644 --- a/src/calibre/ebooks/htmlz/oeb2html.py +++ b/src/calibre/ebooks/htmlz/oeb2html.py @@ -44,6 +44,10 @@ class OEB2HTML(object): def oeb2html(self, oeb_book, opts): self.log.info('Converting OEB book to HTML...') self.opts = opts + try: + self.book_title = unicode(oeb_book.metadata.title[0]) + except Exception: + self.book_title = _('Unknown') self.links = {} self.images = {} self.base_hrefs = [item.href for item in oeb_book.spine] @@ -52,7 +56,10 @@ class OEB2HTML(object): return self.mlize_spine(oeb_book) def mlize_spine(self, oeb_book): - output = [u'<html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /></head><body>'] + output = [ + u'<html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>%s' % ( + prepare_string_for_xml(self.book_title)) + ] for item in oeb_book.spine: self.log.debug('Converting %s to HTML...' % item.href) self.rewrite_ids(item.data, item) @@ -330,8 +337,9 @@ class OEB2HTMLClassCSSizer(OEB2HTML): css = u'' else: css = u'' + title = u'%s' % prepare_string_for_xml(self.book_title) output = [u''] + \ - [css] + [u''] + output + [u''] + [css] + [title, u''] + output + [u''] return ''.join(output) def dump_text(self, elem, stylizer, page):