From 8ea5ddbbaa3d23554b8b95bd6574c542b45b8c62 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 28 Apr 2019 12:51:32 +0530 Subject: [PATCH] Fix a regression in the previous release that caused the conversion of HTML to text in comments when output to catalogs or converting downloaded metadata to behave slightly differently. Fixes #1826654 [Comments in CSV-Catalog](https://bugs.launchpad.net/calibre/+bug/1826654) --- src/calibre/utils/html2text.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/calibre/utils/html2text.py b/src/calibre/utils/html2text.py index ecb5ddbe35..cb6f73f658 100644 --- a/src/calibre/utils/html2text.py +++ b/src/calibre/utils/html2text.py @@ -17,6 +17,9 @@ def html2text(html): r'<\gspan\g>', html) h2t = HTML2Text() h2t.default_image_alt = _('Unnamed image') + h2t.body_width = 0 + h2t.single_line_break = True + h2t.emphasis_mark = '*' return h2t.handle(html) @@ -27,12 +30,13 @@ def find_tests(): def test_html2text_behavior(self): for src, expected in { - 'test': 'test\n\n', - 'test': '_test_\n\n', - 'other': '[other](http://else.where/other)\n\n', - '': '![Unnamed image](test.jpeg)\n\n', - 'test dest': 'test dest\n\n', - '<>a': '<>a\n\n', + 'test': 'test\n', + 'test': '*test*\n', + 'other': '[other](http://else.where/other)\n', + '': '![Unnamed image](test.jpeg)\n', + 'test dest': 'test dest\n', + '<>a': '<>a\n', + '

a

b': 'a\nb\n', }.items(): self.assertEqual(html2text(src), expected)