How to use the justext.core.html_to_dom function in jusText

To help you get started, we’ve selected a few jusText 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 miso-belica / jusText / tests / test_dom_utils.py View on Github external
def test_preprocess_simple_bytes_string(self):
        html_string = (
            b'<title>Title</title>'
            b'<h1>Header</h1>'
            b'<p>pre<span>text</span>post<em>emph</em>popost</p>'
            b'<p>footer <em>like</em> a boss</p>'
            b'  \n'
            b''
        )

        dom = preprocessor(html_to_dom(html_string))
        returned = html.tostring(dom).decode("utf8")
        expected = (
            ''
            '<h1>Header</h1>'
            '<p>pre<span>text</span>post<em>emph</em>popost</p>'
            '<p>footer <em>like</em> a boss</p>'
            '  \n'
            ''
        )
        assert expected == returned
github miso-belica / jusText / tests / test_dom_utils.py View on Github external
def test_preprocess_simple_bytes_xhtml_string_with_declaration(self):
        html_string = (
            b''
            b''
            b''
            b''
            b'<title>Hello World</title>'
            b''
            b''
            b''
            b''
            b''
            b''
        )

        dom = preprocessor(html_to_dom(html_string))
        returned = html.tostring(dom).decode("utf8")
        expected = (
            ''
            ''
            ''
            ''
        )
        assert expected == returned
github miso-belica / jusText / tests / test_dom_utils.py View on Github external
def test_preprocess_simple_unicode_string(self):
        html_string = (
            '<title>Title</title>'
            '<h1>Header</h1>'
            '<p>pre<span>text</span>post<em>emph</em>popost</p>'
            '<p>footer <em>like</em> a boss</p>'
            ''
        )

        dom = preprocessor(html_to_dom(html_string))
        returned = html.tostring(dom).decode("utf8")
        expected = (
            ''
            '<h1>Header</h1>'
            '<p>pre<span>text</span>post<em>emph</em>popost</p>'
            '<p>footer <em>like</em> a boss</p>'
            ''
        )
        assert expected == returned
github miso-belica / jusText / tests / test_dom_utils.py View on Github external
def test_preprocess_simple_unicode_xhtml_string_with_declaration(self):
        html_string = (
            ''
            ''
            ''
            ''
            '<title>Hello World</title>'
            ''
            ''
            ''
            ''
            ''
            ''
        )

        dom = preprocessor(html_to_dom(html_string))
        returned = html.tostring(dom).decode("utf8")
        expected = (
            ''
            ''
            ''
            ''
        )
        assert expected == returned