mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Fix copy all book details not respecting line breaks in fields
This commit is contained in:
parent
e9a0b5dcf1
commit
dcbb72a2b8
@ -92,6 +92,9 @@ def copy_all(text_browser):
|
|||||||
if not is_vertical:
|
if not is_vertical:
|
||||||
parent = tables[1]
|
parent = tables[1]
|
||||||
for tag in parent.iterdescendants('td'):
|
for tag in parent.iterdescendants('td'):
|
||||||
|
for child in tag.iterdescendants('br'):
|
||||||
|
child.tag = 'span'
|
||||||
|
child.text = '\ue000'
|
||||||
tt = etree.tostring(tag, method='text', encoding='unicode')
|
tt = etree.tostring(tag, method='text', encoding='unicode')
|
||||||
tag.tag = 'span'
|
tag.tag = 'span'
|
||||||
for child in tuple(tag):
|
for child in tuple(tag):
|
||||||
@ -105,6 +108,7 @@ def copy_all(text_browser):
|
|||||||
from calibre.utils.html2text import html2text
|
from calibre.utils.html2text import html2text
|
||||||
simplified_html = etree.tostring(root, encoding='unicode')
|
simplified_html = etree.tostring(root, encoding='unicode')
|
||||||
txt = html2text(simplified_html, single_line_break=True).strip()
|
txt = html2text(simplified_html, single_line_break=True).strip()
|
||||||
|
txt = txt.replace('\ue000', '\n\t')
|
||||||
if iswindows:
|
if iswindows:
|
||||||
txt = os.linesep.join(txt.splitlines())
|
txt = os.linesep.join(txt.splitlines())
|
||||||
# print(simplified_html)
|
# print(simplified_html)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user