mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
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:
parent
de18e1fdc2
commit
15e5d7cb11
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user