Metadata jacket: Fix <br> tags in the comments not being rendered correctly when inserting the comments into the jacket page. Fixes #1848327 [Imported metadata is truncated in conversion](https://bugs.launchpad.net/calibre/+bug/1848327)

This commit is contained in:
Kovid Goyal 2019-10-18 08:39:52 +05:30
parent 99ebcf838a
commit a3f4736b4b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -10,8 +10,6 @@ import sys, os, re
from xml.sax.saxutils import escape
from string import Formatter
from lxml import etree
from calibre import guess_type, strftime
from calibre.constants import iswindows
from calibre.ebooks.oeb.base import XPath, XHTML_NS, XHTML, xml2text, urldefrag, urlnormalize
@ -269,7 +267,6 @@ def render_jacket(mi, output_profile,
comments = mi.comments if mi.comments else alt_comments
comments = comments.strip()
orig_comments = comments
if comments:
comments = comments_to_html(comments)
@ -349,17 +346,10 @@ def render_jacket(mi, output_profile,
return strip_encoding_declarations(generated_html)
from calibre.ebooks.oeb.base import RECOVER_PARSER
from calibre.ebooks.oeb.polish.parsing import parse
raw = generate_html(comments)
root = parse(raw, line_numbers=False, force_html5_parse=True)
try:
root = etree.fromstring(generate_html(comments), parser=RECOVER_PARSER)
except:
try:
root = etree.fromstring(generate_html(escape(orig_comments)),
parser=RECOVER_PARSER)
except:
root = etree.fromstring(generate_html(''),
parser=RECOVER_PARSER)
if rescale_fonts:
# We ensure that the conversion pipeline will set the font sizes for
# text in the jacket to the same size as the font sizes for the rest of