How to use the soupsieve.escape function in soupsieve

To help you get started, we’ve selected a few soupsieve 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 zopefoundation / zope.testbrowser / src / zope / testbrowser / browser.py View on Github external
def getLink(self, text=None, url=None, id=None, index=0):
        """See zope.testbrowser.interfaces.IBrowser"""
        qa = 'a' if id is None else 'a#%s' % css_escape(id)
        qarea = 'area' if id is None else 'area#%s' % css_escape(id)
        html = self._html
        links = html.select(qa)
        links.extend(html.select(qarea))

        matching = []
        for elem in links:
            matches = (isMatching(elem.text, text) and
                       isMatching(elem.get('href', ''), url))

            if matches:
                matching.append(elem)

        if index >= len(matching):
            raise LinkNotFoundError()
        elem = matching[index]
github facelessuser / soupsieve / tests / test_api.py View on Github external
def test_escape_numbers(self):
        """Test escape hyphen cases."""

        self.assertEqual(r'\33 ', sv.escape('3'))
        self.assertEqual(r'-\33 ', sv.escape('-3'))
        self.assertEqual(r'--3', sv.escape('--3'))
github facelessuser / soupsieve / tests / test_api.py View on Github external
def test_escape_hyphen(self):
        """Test escape hyphen cases."""

        self.assertEqual(r'\-', sv.escape('-'))
        self.assertEqual(r'--', sv.escape('--'))
github facelessuser / soupsieve / tests / test_api.py View on Github external
def test_escape_numbers(self):
        """Test escape hyphen cases."""

        self.assertEqual(r'\33 ', sv.escape('3'))
        self.assertEqual(r'-\33 ', sv.escape('-3'))
        self.assertEqual(r'--3', sv.escape('--3'))
github facelessuser / soupsieve / tests / test_api.py View on Github external
def test_escape_null(self):
        """Test escape null character."""

        self.assertEqual('\ufffdtest', sv.escape('\x00test'))
github facelessuser / soupsieve / tests / test_api.py View on Github external
def test_escape_special(self):
        """Test escape special character."""

        self.assertEqual(r'\{\}\[\]\ \(\)', sv.escape('{}[] ()'))
github facelessuser / soupsieve / tests / test_api.py View on Github external
def test_escape_ctrl(self):
        """Test escape control character."""

        self.assertEqual(r'\1 test', sv.escape('\x01test'))
github facelessuser / soupsieve / tests / test_api.py View on Github external
def test_escape_wide_unicode(self):
        """Test handling of wide Unicode."""

        self.assertEqual('Emoji\\ \U0001F60D', sv.escape('Emoji \U0001F60D'))
github facelessuser / soupsieve / tests / test_api.py View on Github external
def test_escape_hyphen(self):
        """Test escape hyphen cases."""

        self.assertEqual(r'\-', sv.escape('-'))
        self.assertEqual(r'--', sv.escape('--'))