How to use the telegraph.exceptions.InvalidHTML 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_no_starttag_node(self):
        with self.assertRaises(InvalidHTML):
             html_to_nodes(HTML_NO_STARTTAG)
github python273 / telegraph / tests / test_html_converter.py View on Github external
def test_html_to_nodes_invalid_html(self):
        with self.assertRaises(InvalidHTML):
            html_to_nodes('<p><b></b></p>')
github python273 / telegraph / telegraph / utils.py View on Github external
def handle_endtag(self, tag):
        if tag in VOID_ELEMENTS:
            return

        if not len(self.parent_nodes):
            raise InvalidHTML('"{}" missing start tag'.format(
                tag
            ))

        self.current_nodes = self.parent_nodes.pop()

        last_node = self.current_nodes[-1]

        if last_node['tag'] != tag:
            raise InvalidHTML('"{}" tag closed instead of "{}"'.format(
                tag, last_node['tag']
            ))

        if not last_node['children']:
            last_node.pop('children')
github python273 / telegraph / telegraph / utils.py View on Github external
def get_nodes(self):
        if self.parent_nodes:
            not_closed_tag = self.parent_nodes[-1][-1]['tag']
            raise InvalidHTML('"{}" tag is not closed'.format(not_closed_tag))

        return self.nodes