How to use the telegraph.exceptions.NotAllowedTag function in telegraph

To help you get started, we’ve selected a few telegraph examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python273 / telegraph / tests / test_html_converter.py View on Github external
def test_html_to_nodes_not_allowed_tag(self):
        with self.assertRaises(NotAllowedTag):
            html_to_nodes('')
github python273 / telegraph / telegraph / utils.py View on Github external
def handle_starttag(self, tag, attrs_list):
        if tag not in ALLOWED_TAGS:
            raise NotAllowedTag('%s tag is not allowed' % tag)

        node = {'tag': tag}

        if attrs_list:
            attrs = {}

            for attr, value in attrs_list:
                attrs[attr] = value

            node['attrs'] = attrs

        self.current_nodes.append(node)

        if tag not in VOID_ELEMENTS:
            self.parent_nodes.append(self.current_nodes)
            self.current_nodes = node['children'] = []