How to use the telegraph.utils.nodes_to_html 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_nodes_to_html(self):
        self.assertEqual(
            nodes_to_html(NODES_TEST_LIST),
            HTML_TEST_STR
        )
github python273 / telegraph / tests / test_html_converter.py View on Github external
def test_nodes_to_html_nested(self):
        self.assertEqual(
            nodes_to_html([
                {'tag': 'a', 'children': [
                    {'tag': 'b', 'children': [
                        {'tag': 'c', 'children': [
                            {'tag': 'd', 'children': []}
                        ]}
                    ]}
                ]}
            ]),
            '<a><b></b></a>'
        )
github python273 / telegraph / tests / test_html_converter.py View on Github external
def test_nodes_to_html_blank(self):
        self.assertEqual(
            nodes_to_html([]),
            ''
        )
github python273 / telegraph / telegraph / api.py View on Github external
def get_page(self, path, return_content=True, return_html=True):
        """ Get a Telegraph page

        :param path: Path to the Telegraph page (in the format Title-12-31,
                     i.e. everything that comes after https://telegra.ph/)

        :param return_content: If true, content field will be returned
        :param return_html: If true, returns HTML instead of Nodes list
        """

        response = self._telegraph.method('getPage', path=path, values={
            'return_content': return_content
        })

        if return_content and return_html:
            response['content'] = nodes_to_html(response['content'])

        return response