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)

This commit is contained in:
Kovid Goyal 2019-04-28 12:51:32 +05:30
parent ddbda87137
commit 8ea5ddbbaa
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -17,6 +17,9 @@ def html2text(html):
r'<\g<solidus>span\g<rest>>', 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 {
'<u>test</U>': 'test\n\n',
'<i>test</i>': '_test_\n\n',
'<a href="http://else.where/other">other</a>': '[other](http://else.where/other)\n\n',
'<img src="test.jpeg">': '![Unnamed image](test.jpeg)\n\n',
'<a href="#t">test</a> <span id="t">dest</span>': 'test dest\n\n',
'<>a': '<>a\n\n',
'<u>test</U>': 'test\n',
'<i>test</i>': '*test*\n',
'<a href="http://else.where/other">other</a>': '[other](http://else.where/other)\n',
'<img src="test.jpeg">': '![Unnamed image](test.jpeg)\n',
'<a href="#t">test</a> <span id="t">dest</span>': 'test dest\n',
'<>a': '<>a\n',
'<p>a<p>b': 'a\nb\n',
}.items():
self.assertEqual(html2text(src), expected)