Returns HTML as a BeautifulSoup element.
161345
def soup(self):
        '''
            
        '''
        components_soup = Tag(name=self.tagname, builder=BUILDER)
        components_soup.attrs = self.attributes
        for c in flatten(self.components):
            if hasattr(c, 'soup'):
                components_soup.append(c.soup())
            elif type(c) in (str, ):
                # components_soup.append(BeautifulSoup(str(c)))
                components_soup.append(str(c))
            # else:
                # Component should not be integrated
                # pass
        return components_soup
749997
def get_text(html):
    """"""

    # Ignore warnings made by BeautifulSoup, if passed something that looks like
    # a file (e.g. a dot which matches current dict), it will warn that the file
    # should be opened instead of passing a filename.
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        text = BeautifulSoup(html.replace('&apos;', "'"), "html.parser").get_text()

    return unicodedata.normalize('NFKC', text)
1014398
def _ExtractDataFromShowHtml(self, html):
    
    htmlLines = html.splitlines()
    for count, line in enumerate(htmlLines):
      if line.strip() == r'<pre>':
        startLine = count+1
      if line.strip() == r'</pre>':
        endLine = count

    try:
      dataList = htmlLines[startLine:endLine]
      dataString = '\n'.join(dataList)
      return dataString.strip()
    except:
      raise Exception("Show content not found - check EPGuides html formatting")
67
def get_html_content(self):
        

        # Extract full element node content (including subelements)
        html_content = ''
        if hasattr(self, 'xml_element'):
            xml = self.xml_element
            content_list = ["" if xml.text is None else xml.text]

            def to_string(xml):
                if isinstance(xml, _Comment):
                    return str(xml)
                else:
                    return ElementTree.tostring(xml).decode('utf-8')

            content_list += [to_string(e) for e in xml.getchildren()]

            full_xml_content = "".join(content_list)

            # Parse tags to generate HTML valid content
            first_regex = r'html:'
            second_regex = r' xmlns:html=(["\'])(?:(?=(\\?))\2.)*?\1'
            html_content = re.sub(first_regex, '',
                                  re.sub(second_regex, '', full_xml_content))

        return html_content
1029842
def html(self, unicode=False):
        
        html = lxml.html.tostring(self.element, encoding=self.encoding)
        if unicode:
            html = html.decode(self.encoding)
        return html
518992
def innerHTML(self) -> str:
        """"""
        if self._inner_element:
            return self._inner_element.innerHTML
        return super().innerHTML
76364
def content(self, output=None, str_output=None, **kwargs):
        """"""
        if self.response.mimetype != "text/html":
            raise Failure(_("expected request to return HTML, but it returned {}").format(
                self.response.mimetype))

        # TODO: Remove once beautiful soup updates to accomodate python 3.7
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", category=DeprecationWarning)
            content = BeautifulSoup(self.response.data, "html.parser")

        return self._search_page(
            output,
            str_output,
            content,
            lambda regex, content: any(regex.search(str(tag)) for tag in content.find_all(**kwargs)))
864276
def __get_html(self, body=None):
        

        output = []
        output.append("<html>")
        output.append("<head>")
        for javascript in (self.__jquery_javascript,
                           self.__crittercism_javascript,
                           self.__reporter_javascript):
            output.append("<script type=\"text/javascript\">")
            output.append(javascript)
            output.append("</script>")
        output.append("<style type=\"text/css\">")
        output.append(self.__style)
        output.append("</style>")
        output.append("</head>")
        if body is not None:
            output.append(body)
        else:
            output.append("<body>")
            output.append("<div id=\"report\">")
            output.append("</div>")
            output.append("</body>")
        output.append("</html>")
        return "\n".join(output)
970415
def clone(self):
        '''
        
        '''
        return HtmlElement(self.tag, self.prefix, self.suffix, self.display,
                           self.margin_before, self.margin_after, self.padding,
                           self.whitespace)
170777
def html(content, **kwargs):
    """"""
    if hasattr(content, 'read'):
        return content
    elif hasattr(content, 'render'):
        return content.render().encode('utf8')

    return str(content).encode('utf8')
1281809
def soup(self):
        '''
            
        '''
        dom = BeautifulSoup('<!DOCTYPE html>')

        # BeautifulSoup behaves differently if lxml is installed or not,
        # and will create a basic HTML structure if lxml is installed.
        if len(dom) > 1:
            list(dom.children)[1].replaceWith('')  # Removing default content

        soup = Element.soup(self)
        dom.append(soup)

        for plugin in self.plugins(deduplicate=True):
            dom = plugin(dom)

        return dom
922232
def parse_html(self, text):
        
        bs = BeautifulSoup(text, "html5lib")
        file_reg = re.compile(MARKDOWN_IMAGE_REGEX, flags=re.IGNORECASE)
        tags = bs.findAll('img')

        for tag in tags:
            # Look for src attribute, remove formatting if added to image
            src_text = tag.get("src") or ""
            formatted_src_match = file_reg.search(src_text)
            src_text = formatted_src_match.group(2) if formatted_src_match else src_text

            alt_text = tag.get("alt") or ""
            tag.replaceWith("![{alt}]({src})".format(alt=alt_text, src=src_text))
        return html.unescape(bs.find('body').renderContents().decode('utf-8'))
1159938
def parse_html(infile, xpath):
    """"""
    if not isinstance(infile, lh.HtmlElement):
        infile = lh.fromstring(infile)
    infile = infile.xpath(xpath)
    if not infile:
        raise ValueError('XPath {0} returned no results.'.format(xpath))
    return infile
724925
def doc_to_html(doc, doc_format="ROBOT"):
    """"""
    from robot.libdocpkg.htmlwriter import DocToHtml
    return DocToHtml(doc_format)(doc)
471854
public Html getHtml() {
        if (html == null) {
            html = new Html(rawText, request.getUrl());
        }
        return html;
    }
348399
def Element(cls, s, *args):
        """"""
        sargs = []
        for arg in args:
            if type(arg) == etree._Element:
                sargs.append(etree.tounicode(arg))
            else:
                sargs.append(arg)
        if type(s) == etree._Element:
            t = etree.tounicode(s)
        else:
            t = s
        if len(args) == 0:
            return XML.fromstring(t)
        else:
            return XML.fromstring(t % tuple(sargs))
731728
def absolute_urls(html):
    

    from bs4 import BeautifulSoup
    from yacms.core.request import current_request

    request = current_request()
    if request is not None:
        dom = BeautifulSoup(html, "html.parser")
        for tag, attr in ABSOLUTE_URL_TAGS.items():
            for node in dom.findAll(tag):
                url = node.get(attr, "")
                if url:
                    node[attr] = request.build_absolute_uri(url)
        html = str(dom)
    return html