Edit Book: Fix style attribute on <html> tags not being preserved. Fixes #1810193 [ebook-edit drops STYLE attribute from HTML tags](https://bugs.launchpad.net/calibre/+bug/1810193)

This commit is contained in:
Kovid Goyal 2019-01-02 09:28:34 +05:30
parent 84326d407c
commit dde3ae0416
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -59,6 +59,7 @@ def node_from_path(root, path):
parent = parent[idx] parent = parent[idx]
return parent return parent
mychr = chr if ispy3 else unichr mychr = chr if ispy3 else unichr
@ -227,6 +228,8 @@ class Chunker(object):
attrib = {'lang':lang} if lang else {} attrib = {'lang':lang} if lang else {}
if 'class' in root.attrib: if 'class' in root.attrib:
attrib['class'] = root.attrib['class'] attrib['class'] = root.attrib['class']
if 'style' in root.attrib:
attrib['style'] = root.attrib['style']
nroot = etree.Element('html', attrib=attrib) nroot = etree.Element('html', attrib=attrib)
nroot.text = root.text nroot.text = root.text
nroot.tail = '\n' nroot.tail = '\n'
@ -442,5 +445,3 @@ class Chunker(object):
'tool on the orig and rebuilt directories') 'tool on the orig and rebuilt directories')
else: else:
self.log('Skeleton HTML before and after is identical.') self.log('Skeleton HTML before and after is identical.')