From 00d44590717b90d77f97db33b7384b1b811864a7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 3 Feb 2022 13:21:38 +0530 Subject: [PATCH] Amazon metadata download: Fix paragraphs in the comments being merged. Fixes #1959659 [Metadata download: preserve paragraph tags in comments](https://bugs.launchpad.net/calibre/+bug/1959659) --- src/calibre/library/comments.py | 2 +- src/calibre/utils/html2text.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/calibre/library/comments.py b/src/calibre/library/comments.py index 9fc14d9c0d..fe3853d656 100644 --- a/src/calibre/library/comments.py +++ b/src/calibre/library/comments.py @@ -143,7 +143,7 @@ def merge_comments(one, two): def sanitize_comments_html(html): from calibre.ebooks.markdown import Markdown - text = html2text(html) + text = html2text(html, single_line_break=False) md = Markdown() html = md.convert(text) return html diff --git a/src/calibre/utils/html2text.py b/src/calibre/utils/html2text.py index e7a6d1dd13..82abab99e8 100644 --- a/src/calibre/utils/html2text.py +++ b/src/calibre/utils/html2text.py @@ -2,7 +2,7 @@ # License: GPLv3 Copyright: 2019, Kovid Goyal -def html2text(html): +def html2text(html, single_line_break=True): from html2text import HTML2Text import re if isinstance(html, bytes): @@ -15,7 +15,7 @@ def html2text(html): h2t = HTML2Text() h2t.default_image_alt = _('Unnamed image') h2t.body_width = 0 - h2t.single_line_break = True + h2t.single_line_break = single_line_break h2t.emphasis_mark = '*' return h2t.handle(html)