Skip to content

Commit

Permalink
Fix HtmlToNodesParser again
Browse files Browse the repository at this point in the history
  • Loading branch information
python273 committed Aug 26, 2017
1 parent 9dd41bb commit d4b9dd7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions telegraph/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def __init__(self):
self.parent_nodes = []

def add_str_node(self, s):
if not s:
return

if self.current_nodes and isinstance(self.current_nodes[-1], basestring):
self.current_nodes[-1] += s
else:
Expand Down Expand Up @@ -75,10 +78,7 @@ def handle_endtag(self, tag):
last_node.pop('children')

def handle_data(self, data):
if data == '\n':
return

self.add_str_node(data)
self.add_str_node(data.strip())

def handle_entityref(self, name):
self.add_str_node(chr(name2codepoint[name]))
Expand Down

0 comments on commit d4b9dd7

Please sign in to comment.