mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
ddbda87137
commit
8ea5ddbbaa
@ -17,6 +17,9 @@ def html2text(html):
|
|||||||
r'<\g<solidus>span\g<rest>>', html)
|
r'<\g<solidus>span\g<rest>>', html)
|
||||||
h2t = HTML2Text()
|
h2t = HTML2Text()
|
||||||
h2t.default_image_alt = _('Unnamed image')
|
h2t.default_image_alt = _('Unnamed image')
|
||||||
|
h2t.body_width = 0
|
||||||
|
h2t.single_line_break = True
|
||||||
|
h2t.emphasis_mark = '*'
|
||||||
return h2t.handle(html)
|
return h2t.handle(html)
|
||||||
|
|
||||||
|
|
||||||
@ -27,12 +30,13 @@ def find_tests():
|
|||||||
|
|
||||||
def test_html2text_behavior(self):
|
def test_html2text_behavior(self):
|
||||||
for src, expected in {
|
for src, expected in {
|
||||||
'<u>test</U>': 'test\n\n',
|
'<u>test</U>': 'test\n',
|
||||||
'<i>test</i>': '_test_\n\n',
|
'<i>test</i>': '*test*\n',
|
||||||
'<a href="http://else.where/other">other</a>': '[other](http://else.where/other)\n\n',
|
'<a href="http://else.where/other">other</a>': '[other](http://else.where/other)\n',
|
||||||
'<img src="test.jpeg">': '\n\n',
|
'<img src="test.jpeg">': '\n',
|
||||||
'<a href="#t">test</a> <span id="t">dest</span>': 'test dest\n\n',
|
'<a href="#t">test</a> <span id="t">dest</span>': 'test dest\n',
|
||||||
'<>a': '<>a\n\n',
|
'<>a': '<>a\n',
|
||||||
|
'<p>a<p>b': 'a\nb\n',
|
||||||
}.items():
|
}.items():
|
||||||
self.assertEqual(html2text(src), expected)
|
self.assertEqual(html2text(src), expected)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user