mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
pep8
This commit is contained in:
parent
32de3c16ea
commit
ddbff0f23d
@ -44,8 +44,10 @@ META_XP = XPath('/h:html/h:head/h:meta[@http-equiv="Content-Type"]')
|
|||||||
|
|
||||||
def merge_multiple_html_heads_and_bodies(root, log=None):
|
def merge_multiple_html_heads_and_bodies(root, log=None):
|
||||||
heads, bodies = xpath(root, '//h:head'), xpath(root, '//h:body')
|
heads, bodies = xpath(root, '//h:head'), xpath(root, '//h:body')
|
||||||
if not (len(heads) > 1 or len(bodies) > 1): return root
|
if not (len(heads) > 1 or len(bodies) > 1):
|
||||||
for child in root: root.remove(child)
|
return root
|
||||||
|
for child in root:
|
||||||
|
root.remove(child)
|
||||||
head = root.makeelement(XHTML('head'))
|
head = root.makeelement(XHTML('head'))
|
||||||
body = root.makeelement(XHTML('body'))
|
body = root.makeelement(XHTML('body'))
|
||||||
for h in heads:
|
for h in heads:
|
||||||
@ -368,8 +370,7 @@ def parse_html(data, log=None, decoder=None, preprocessor=None,
|
|||||||
meta.getparent().remove(meta)
|
meta.getparent().remove(meta)
|
||||||
meta = etree.SubElement(head, XHTML('meta'),
|
meta = etree.SubElement(head, XHTML('meta'),
|
||||||
attrib={'http-equiv': 'Content-Type'})
|
attrib={'http-equiv': 'Content-Type'})
|
||||||
meta.set('content', 'text/html; charset=utf-8') # Ensure content is second
|
meta.set('content', 'text/html; charset=utf-8') # Ensure content is second attribute
|
||||||
# attribute
|
|
||||||
|
|
||||||
# Ensure has a <body/>
|
# Ensure has a <body/>
|
||||||
if not xpath(data, '/h:html/h:body'):
|
if not xpath(data, '/h:html/h:body'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user