Skip to content

Commit d4b9dd7

Browse files
committed
Fix HtmlToNodesParser again
1 parent 9dd41bb commit d4b9dd7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

telegraph/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def __init__(self):
3939
self.parent_nodes = []
4040

4141
def add_str_node(self, s):
42+
if not s:
43+
return
44+
4245
if self.current_nodes and isinstance(self.current_nodes[-1], basestring):
4346
self.current_nodes[-1] += s
4447
else:
@@ -75,10 +78,7 @@ def handle_endtag(self, tag):
7578
last_node.pop('children')
7679

7780
def handle_data(self, data):
78-
if data == '\n':
79-
return
80-
81-
self.add_str_node(data)
81+
self.add_str_node(data.strip())
8282

8383
def handle_entityref(self, name):
8484
self.add_str_node(chr(name2codepoint[name]))

0 commit comments

Comments
 (0)