mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Fix handling of comments in the jacket template
This commit is contained in:
parent
2d6d6eb76f
commit
055b17c68a
@ -38,9 +38,12 @@
|
|||||||
<hr class="cbj_kindle_banner_hr" />
|
<hr class="cbj_kindle_banner_hr" />
|
||||||
<!--
|
<!--
|
||||||
In addition you can add code to show the values of custom columns here.
|
In addition you can add code to show the values of custom columns here.
|
||||||
The value is available as _column_name and the title as _column_name_label.
|
The value is available as _column_name and the title as
|
||||||
For example, if you have a custom column with label #genre, you can add it to
|
_column_name_label. For example, if you have a custom column with
|
||||||
this template with _genre_label and _genre. Note that the # is replaced by an underscore.
|
label #genre, you can add it to this template with _genre_label and
|
||||||
|
_genre. Note that the # is replaced by an underscore. For example
|
||||||
|
|
||||||
|
<div><b>{_genre_label}:</b> {_genre}</div>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<div class="cbj_comments">{comments}</div>
|
<div class="cbj_comments">{comments}</div>
|
||||||
|
@ -16,6 +16,7 @@ from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
|||||||
from calibre.ebooks.oeb.base import XPath, XHTML_NS, XHTML
|
from calibre.ebooks.oeb.base import XPath, XHTML_NS, XHTML
|
||||||
from calibre.library.comments import comments_to_html
|
from calibre.library.comments import comments_to_html
|
||||||
from calibre.utils.date import is_date_undefined
|
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"]'
|
JACKET_XPATH = '//h:meta[@name="calibre-content" and @content="jacket"]'
|
||||||
|
|
||||||
@ -180,10 +181,14 @@ def render_jacket(mi, output_profile,
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
args['_genre_label'] = args.get('_genre_label', '')
|
||||||
|
args['_genre'] = args.get('_genre', '')
|
||||||
|
|
||||||
generated_html = P('jacket/template.xhtml',
|
generated_html = P('jacket/template.xhtml',
|
||||||
data=True).decode('utf-8').format(**args)
|
data=True).decode('utf-8').format(**args)
|
||||||
|
|
||||||
# Post-process the generated html to strip out empty header items
|
# Post-process the generated html to strip out empty header items
|
||||||
|
|
||||||
soup = BeautifulSoup(generated_html)
|
soup = BeautifulSoup(generated_html)
|
||||||
if not series:
|
if not series:
|
||||||
series_tag = soup.find(attrs={'class':'cbj_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:
|
if hr_tag is not None:
|
||||||
hr_tag.extract()
|
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
|
from calibre.ebooks.oeb.base import RECOVER_PARSER
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user