FB2 Output: Fix comments from the input document not present in the output. Fixes #1815357 [Field "Comments" are lost when converting epub to fb2](https://bugs.launchpad.net/calibre/+bug/1815357)

This commit is contained in:
Kovid Goyal 2019-02-11 13:50:28 +05:30
parent de18e1fdc2
commit 15e5d7cb11
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -185,6 +185,14 @@ class FB2MLizer(object):
if key not in ('author', 'cover', 'sequence', 'keywords', 'year', 'publisher', 'isbn'): if key not in ('author', 'cover', 'sequence', 'keywords', 'year', 'publisher', 'isbn'):
metadata[key] = prepare_string_for_xml(value) metadata[key] = prepare_string_for_xml(value)
try:
comments = self.oeb_book.metadata['description'][0]
except Exception:
metadata['comments'] = ''
else:
from calibre.utils.html2text import html2text
metadata['comments'] = '<annotation>{}</annotation>'.format(prepare_string_for_xml(html2text(comments.value.strip())))
return textwrap.dedent(u''' return textwrap.dedent(u'''
<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:xlink="http://www.w3.org/1999/xlink"> <FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:xlink="http://www.w3.org/1999/xlink">
<description> <description>
@ -196,6 +204,7 @@ class FB2MLizer(object):
<lang>%(lang)s</lang> <lang>%(lang)s</lang>
%(keywords)s %(keywords)s
%(sequence)s %(sequence)s
%(comments)s
</title-info> </title-info>
<document-info> <document-info>
%(author)s %(author)s