def handle_starttag(self, tag, attrs):
if self.hide_output:
return
if self.tag_count != 0 and tag != "img": # img is always self-closed
self.tag_count += 1
if tag in SUPPORTED_TAGS and (self.tag_count == 0):
self.push_tag("<"+tag+">")
self.current_tag = tag
elif tag == "a" and (self.tag_count == 0):
href = find_href(attrs)
if href:
self.push_tag("<a href='{0}'>".format(html.escape(href, quote=True)))
self.current_tag = "a"
elif tag in ('p', 'br', 'div', 'table', 'dt', 'dd', 'li', 'tr'):
self.push_newlines(2)
elif tag == 'td':
self.push_newlines(1)
elif tag in ('script', 'style'):
self.hide_output = True
评论列表
文章目录