diff --git a/resources/jacket/template.xhtml b/resources/jacket/template.xhtml index 17d0493a82..671ca5a04d 100644 --- a/resources/jacket/template.xhtml +++ b/resources/jacket/template.xhtml @@ -38,9 +38,12 @@
{comments}
diff --git a/src/calibre/ebooks/oeb/transforms/jacket.py b/src/calibre/ebooks/oeb/transforms/jacket.py index 987fe0ce86..ede34ef17c 100644 --- a/src/calibre/ebooks/oeb/transforms/jacket.py +++ b/src/calibre/ebooks/oeb/transforms/jacket.py @@ -16,6 +16,7 @@ from calibre.ebooks.BeautifulSoup import BeautifulSoup from calibre.ebooks.oeb.base import XPath, XHTML_NS, XHTML from calibre.library.comments import comments_to_html from calibre.utils.date import is_date_undefined +from calibre.ebooks.chardet import strip_encoding_declarations JACKET_XPATH = '//h:meta[@name="calibre-content" and @content="jacket"]' @@ -180,10 +181,14 @@ def render_jacket(mi, output_profile, except: pass + args['_genre_label'] = args.get('_genre_label', '') + args['_genre'] = args.get('_genre', '') + generated_html = P('jacket/template.xhtml', data=True).decode('utf-8').format(**args) # Post-process the generated html to strip out empty header items + soup = BeautifulSoup(generated_html) if not series: series_tag = soup.find(attrs={'class':'cbj_series'}) @@ -206,7 +211,8 @@ def render_jacket(mi, output_profile, if hr_tag is not None: hr_tag.extract() - return soup.renderContents(None) + return strip_encoding_declarations( + soup.renderContents('utf-8').decode('utf-8')) from calibre.ebooks.oeb.base import RECOVER_PARSER