From 2afea497a381d6434d92328abe1ee7a99d7044fa Mon Sep 17 00:00:00 2001 From: pictuga Date: Mon, 17 Jul 2017 00:06:39 +0200 Subject: [PATCH] readabilite: br2p use "node" instead of "item" Confusing with rss items otherwise --- morss/readabilite.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/morss/readabilite.py b/morss/readabilite.py index 5a71a62..36abe42 100644 --- a/morss/readabilite.py +++ b/morss/readabilite.py @@ -155,8 +155,8 @@ def clean_html(root): def br2p(root): - for item in list(root.iterfind('.//br')): - parent = item.getparent() + for node in list(root.iterfind('.//br')): + parent = node.getparent() if parent is None: continue @@ -164,23 +164,23 @@ def br2p(root): if gdparent is None: continue - if item.tail is None: + if node.tail is None: # if
is at the end of a div (to avoid having

) continue else: - # set up new item - new_item = lxml.html.Element(parent.tag) - new_item.text = item.tail + # set up new node + new_node = lxml.html.Element(parent.tag) + new_node.text = node.tail - for child in item.itersiblings(): - new_item.append(child) + for child in node.itersiblings(): + new_node.append(child) # delete br - item.tail = None - parent.remove(item) + node.tail = None + 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):