How to use the telegraph.utils.html_to_nodes 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_multi_line(self):
        self.assertEqual(
            html_to_nodes(HTML_MULTI_LINES),
            HTML_MULTI_LINES_NODES_LIST
        )
        self.assertEqual(
            html_to_nodes(HTML_MULTI_LINES1),
            HTML_MULTI_LINES_NODES_LIST
        )
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 / 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 / tests / test_html_converter.py View on Github external
def test_html_to_nodes(self):
        self.assertEqual(
            html_to_nodes(HTML_TEST_STR),
            NODES_TEST_LIST
        )
github python273 / telegraph / tests / test_html_converter.py View on Github external
def test_html_to_nodes_multi_line(self):
        self.assertEqual(
            html_to_nodes(HTML_MULTI_LINES),
            HTML_MULTI_LINES_NODES_LIST
        )
        self.assertEqual(
            html_to_nodes(HTML_MULTI_LINES1),
            HTML_MULTI_LINES_NODES_LIST
        )
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 / telegraph / api.py View on Github external
:param title: Page title

        :param content: Content in nodes list format (see doc)

        :param html_content: Content in HTML format

        :param author_name: Author name, displayed below the article's title

        :param author_url: Profile link, opened when users click on
                           the author's name below the title

        :param return_content: If true, a content field will be returned
        """

        if content is None:
            content = html_to_nodes(html_content)

        content_json = json.dumps(content, ensure_ascii=False)

        return self._telegraph.method('createPage', values={
            'title': title,
            'author_name': author_name,
            'author_url': author_url,
            'content': content_json,
            'return_content': return_content
        })
github python273 / telegraph / telegraph / api.py View on Github external
:param title: Page title

        :param content: Content in nodes list format (see doc)

        :param html_content: Content in HTML format

        :param author_name: Author name, displayed below the article's title

        :param author_url: Profile link, opened when users click on
                           the author's name below the title

        :param return_content: If true, a content field will be returned
        """

        if content is None:
            content = html_to_nodes(html_content)

        content_json = json.dumps(content, ensure_ascii=False)

        return self._telegraph.method('editPage', path=path, values={
            'title': title,
            'author_name': author_name,
            'author_url': author_url,
            'content': content_json,
            'return_content': return_content
        })