html2tele.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:progrobot 作者: petr-kalinin 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号