mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-07 07:24:51 +00:00
Fix HTML parsing breaking with no tags
This commit is contained in:
parent
8e0182633f
commit
cac0bcabf9
1 changed files with 5 additions and 1 deletions
|
|
@ -93,7 +93,10 @@ class Parser(HTMLParser):
|
||||||
self.text += data
|
self.text += data
|
||||||
|
|
||||||
def handle_endtag(self, tag):
|
def handle_endtag(self, tag):
|
||||||
start_tag = self.tags.pop()
|
try:
|
||||||
|
start_tag = self.tags.pop()
|
||||||
|
except IndexError:
|
||||||
|
return
|
||||||
|
|
||||||
if start_tag != tag:
|
if start_tag != tag:
|
||||||
line, offset = self.getpos()
|
line, offset = self.getpos()
|
||||||
|
|
@ -113,6 +116,7 @@ class HTML:
|
||||||
|
|
||||||
def parse(self, text: str):
|
def parse(self, text: str):
|
||||||
text = utils.add_surrogates(str(text or "").strip())
|
text = utils.add_surrogates(str(text or "").strip())
|
||||||
|
text = "<p>{}</p>".format(text)
|
||||||
|
|
||||||
parser = Parser(self.client)
|
parser = Parser(self.client)
|
||||||
parser.feed(text)
|
parser.feed(text)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue