readabilite: br2p use "node" instead of "item"
Confusing with rss items otherwisemaster
parent
843dc97fbf
commit
2afea497a3
|
@ -155,8 +155,8 @@ def clean_html(root):
|
||||||
|
|
||||||
|
|
||||||
def br2p(root):
|
def br2p(root):
|
||||||
for item in list(root.iterfind('.//br')):
|
for node in list(root.iterfind('.//br')):
|
||||||
parent = item.getparent()
|
parent = node.getparent()
|
||||||
if parent is None:
|
if parent is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -164,23 +164,23 @@ def br2p(root):
|
||||||
if gdparent is None:
|
if gdparent is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if item.tail is None:
|
if node.tail is None:
|
||||||
# if <br/> is at the end of a div (to avoid having <p/>)
|
# if <br/> is at the end of a div (to avoid having <p/>)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# set up new item
|
# set up new node
|
||||||
new_item = lxml.html.Element(parent.tag)
|
new_node = lxml.html.Element(parent.tag)
|
||||||
new_item.text = item.tail
|
new_node.text = node.tail
|
||||||
|
|
||||||
for child in item.itersiblings():
|
for child in node.itersiblings():
|
||||||
new_item.append(child)
|
new_node.append(child)
|
||||||
|
|
||||||
# delete br
|
# delete br
|
||||||
item.tail = None
|
node.tail = None
|
||||||
parent.remove(item)
|
parent.remove(node)
|
||||||
|
|
||||||
gdparent.insert(gdparent.index(parent)+1, new_item)
|
gdparent.insert(gdparent.index(parent)+1, new_node)
|
||||||
|
|
||||||
|
|
||||||
def lowest_common_ancestor(nodeA, nodeB, max_depth=None):
|
def lowest_common_ancestor(nodeA, nodeB, max_depth=None):
|
||||||
|
|
Loading…
Reference in New Issue