From 15e5d7cb11d6a1f89951c7dbed84de4ad04d94fa Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 11 Feb 2019 13:50:28 +0530 Subject: [PATCH] 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) --- src/calibre/ebooks/fb2/fb2ml.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/calibre/ebooks/fb2/fb2ml.py b/src/calibre/ebooks/fb2/fb2ml.py index a1981e01ee..d01dd494d3 100644 --- a/src/calibre/ebooks/fb2/fb2ml.py +++ b/src/calibre/ebooks/fb2/fb2ml.py @@ -185,6 +185,14 @@ class FB2MLizer(object): if key not in ('author', 'cover', 'sequence', 'keywords', 'year', 'publisher', 'isbn'): 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'] = '{}'.format(prepare_string_for_xml(html2text(comments.value.strip()))) + return textwrap.dedent(u''' @@ -196,6 +204,7 @@ class FB2MLizer(object): %(lang)s %(keywords)s %(sequence)s + %(comments)s %(author)s