mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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)
This commit is contained in:
parent
68b08f4a6a
commit
00d4459071
@ -143,7 +143,7 @@ def merge_comments(one, two):
|
|||||||
|
|
||||||
def sanitize_comments_html(html):
|
def sanitize_comments_html(html):
|
||||||
from calibre.ebooks.markdown import Markdown
|
from calibre.ebooks.markdown import Markdown
|
||||||
text = html2text(html)
|
text = html2text(html, single_line_break=False)
|
||||||
md = Markdown()
|
md = Markdown()
|
||||||
html = md.convert(text)
|
html = md.convert(text)
|
||||||
return html
|
return html
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# License: GPLv3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
|
||||||
def html2text(html):
|
def html2text(html, single_line_break=True):
|
||||||
from html2text import HTML2Text
|
from html2text import HTML2Text
|
||||||
import re
|
import re
|
||||||
if isinstance(html, bytes):
|
if isinstance(html, bytes):
|
||||||
@ -15,7 +15,7 @@ def html2text(html):
|
|||||||
h2t = HTML2Text()
|
h2t = HTML2Text()
|
||||||
h2t.default_image_alt = _('Unnamed image')
|
h2t.default_image_alt = _('Unnamed image')
|
||||||
h2t.body_width = 0
|
h2t.body_width = 0
|
||||||
h2t.single_line_break = True
|
h2t.single_line_break = single_line_break
|
||||||
h2t.emphasis_mark = '*'
|
h2t.emphasis_mark = '*'
|
||||||
return h2t.handle(html)
|
return h2t.handle(html)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user