How to use the justext.core.preprocessor 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_remove_head_tag(self):
        html_string = (
            '<title>Title</title>'
            '<h1>Header</h1>'
            '<p><span>text</span></p>'
            '<p>footer <em>like</em> a boss</p>'
            ''
        )

        dom = html.fromstring(html_string)
        returned = html.tostring(dom).decode("utf8")
        assert html_string == returned

        dom = preprocessor(dom)
        returned = html.tostring(dom).decode("utf8")
        expected = (
            ''
            '<h1>Header</h1>'
            '<p><span>text</span></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_remove_comments(self):
        dom = html.fromstring(
            ''
            '<h1>Header</h1>'
            ' text'
            '<p>footer'
            ''
        )

        expected = '</p><h1>Header</h1> text<p>footer</p>'
        returned = html.tostring(dom).decode("utf8")
        assert expected == returned

        dom = preprocessor(dom)

        expected = '<h1>Header</h1> text<p>footer</p>'
        returned = html.tostring(dom).decode("utf8")
        assert expected == returned