File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,11 @@ def handle_endtag(self, tag):
8383 if tag in VOID_ELEMENTS :
8484 return
8585
86+ if not len (self .parent_nodes ):
87+ raise InvalidHTML ('"{}" missing start tag' .format (
88+ tag
89+ ))
90+
8691 self .current_nodes = self .parent_nodes .pop ()
8792
8893 last_node = self .current_nodes [- 1 ]
Original file line number Diff line number Diff line change 1919 'attrs' : {'href' : 'https://telegra.ph/' },
2020 'children' : ['Test link</a>' ]
2121 }]
22- },
22+ },
2323 {'tag' : 'figure' , 'children' : [
2424 {'tag' : 'img' , 'attrs' : {'src' : '/file/6c2ecfdfd6881d37913fa.png' }},
2525 {'tag' : 'figcaption' }
4545 ]},
4646]
4747
48+ HTML_NO_STARTTAG = "</a><h1></h1>"
49+
4850
4951class TestHTMLConverter (TestCase ):
5052 def test_html_to_nodes (self ):
@@ -130,3 +132,7 @@ def test_clear_whitespace_nodes(self):
130132 ]
131133
132134 self .assertEqual (clear_whitespace_nodes (nodes )[0 ], expected )
135+
136+ def test_no_starttag_node (self ):
137+ with self .assertRaises (InvalidHTML ):
138+ html_to_nodes (HTML_NO_STARTTAG )
You can’t perform that action at this time.
0 commit comments