How to use the html5lib.treebuilders._base.TreeBuilder function in html5lib

To help you get started, we’ve selected a few html5lib 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 guillemhs / ScraperBot / examples_and_tests / scrapy / Bot4u / build / lxml / build / lib.linux-i686-2.7 / lxml / html / _html5builder.py View on Github external
def insertComment(self, data, parent=None):
        if not self.rootInserted:
            self.initialComments.append(data)
        else:
            _base.TreeBuilder.insertComment(self, data, parent)
github wwqgtxx / wwqLyParse / wwqLyParse / lib / python-3.6.3-embed-amd64 / lxml / html / _html5builder.py View on Github external
def insertComment(self, data, parent=None):
        if not self.rootInserted:
            self.initialComments.append(data)
        else:
            _base.TreeBuilder.insertComment(self, data, parent)
github phyllisstein / alp / alp / request / bs4 / builder / _html5lib.py View on Github external
def getFragment(self):
        return html5lib.treebuilders._base.TreeBuilder.getFragment(self).element
github inasafe / inasafe / third_party / bs4 / builder / _html5lib.py View on Github external
# charEncoding to UTF-8 if it gets Unicode input.
            doc.original_encoding = None
        else:
            doc.original_encoding = parser.tokenizer.stream.charEncoding[0]

    def create_treebuilder(self, namespaceHTMLElements):
        self.underlying_builder = TreeBuilderForHtml5lib(
            self.soup, namespaceHTMLElements)
        return self.underlying_builder

    def test_fragment_to_document(self, fragment):
        """See `TreeBuilder`."""
        return u'%s' % fragment


class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):

    def __init__(self, soup, namespaceHTMLElements):
        self.soup = soup
        super(TreeBuilderForHtml5lib, self).__init__(namespaceHTMLElements)

    def documentClass(self):
        self.soup.reset()
        return Element(self.soup, self.soup, None)

    def insertDoctype(self, token):
        name = token["name"]
        publicId = token["publicId"]
        systemId = token["systemId"]

        doctype = Doctype.for_name_and_ids(name, publicId, systemId)
        self.soup.object_was_parsed(doctype)
github pymedusa / Medusa / ext2 / bs4 / builder / _html5lib.py View on Github external
def getFragment(self):
        return treebuilder_base.TreeBuilder.getFragment(self).element
github clinton-hall / nzbToMedia / libs / py2 / bs4 / builder / _html5lib.py View on Github external
def getFragment(self):
        return treebuilder_base.TreeBuilder.getFragment(self).element
github inasafe / inasafe / third_party / bs4 / builder / _html5lib.py View on Github external
def getFragment(self):
        return html5lib.treebuilders._base.TreeBuilder.getFragment(self).element
github betonme / e2openplugin-SeriesPlugin / src / Identifiers / bs4 / builder / _html5lib.py View on Github external
# charEncoding to UTF-8 if it gets Unicode input.
            doc.original_encoding = None
        else:
            doc.original_encoding = parser.tokenizer.stream.charEncoding[0]

    def create_treebuilder(self, namespaceHTMLElements):
        self.underlying_builder = TreeBuilderForHtml5lib(
            self.soup, namespaceHTMLElements)
        return self.underlying_builder

    def test_fragment_to_document(self, fragment):
        """See `TreeBuilder`."""
        return u'%s' % fragment


class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):

    def __init__(self, soup, namespaceHTMLElements):
        self.soup = soup
        super(TreeBuilderForHtml5lib, self).__init__(namespaceHTMLElements)

    def documentClass(self):
        self.soup.reset()
        return Element(self.soup, self.soup, None)

    def insertDoctype(self, token):
        name = token["name"]
        publicId = token["publicId"]
        systemId = token["systemId"]

        doctype = Doctype.for_name_and_ids(name, publicId, systemId)
        self.soup.object_was_parsed(doctype)