How to use the bs4.Comment function in bs4

To help you get started, we’ve selected a few bs4 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 WanghongLin / miscellaneous / tools / doxygen-c-api-qtcreator-fix.py View on Github external
if memitems:
        for item in memitems:
          memname = item.find('td', {'class': 'memname'})
          memdoc = item.find('div', {'class': 'memdoc'})
          if memdoc and memname > 0:
            html_text = memname.get_text()
            names = html_text.strip(' ').split(' ')
            # Only handle function call name
            # ffmpeg av_xxxxx
            # int function_call_name
            if len(names) == 2 and names[1].startswith('av'):
              # TODO:merge multiple <p> tags in memdoc
              # QtCreator only pick the first </p><p> tag to display in the tooltips
              marker_start = u' $$${0}[overload1]$$$ '.format(names[1])
              marker_end = u' @@@{0} '.format(names[1])
              memdoc.insert_before(Comment(marker_start))
              memdoc.insert_after(Comment(marker_end))
              should_write_back_to_file = True
          pass
    if should_write_back_to_file:
      print 'insert QtCreator style marker for %s' % html_file.name
      html_file.seek(0)
      # DO NOT prettify
      # for the code in the html, use unicode is more readable
      html_file.write(unicode(html_soup).encode('utf-8'))
    html_file.close()
    pass

  src_file.close()
  dst_file.close()

  print 'Done, /path/to/qhelpgenerator %s -o index.qch' % dst_file.name</p>
github k4cg / nichtparasoup / templates_raw / _lib / buildHTMLfromParts.py View on Github external
    for comment in doc.find_all(text=lambda text: isinstance(text, Comment)):
        comment.extract()
github orf / HtmlToWord / wordinserter / parsers / html.py View on Github external
def build_element(self, element, whitespace="ignore"):
        if isinstance(element, bs4.Comment):
            return None

        if isinstance(element, bs4.NavigableString):
            if element.isspace():
                if whitespace == "preserve":
                    return Text(text=str(element))
                elif whitespace == "ignore":
                    return None
                elif whitespace == "respect":
                    if isinstance(element.previous_sibling, bs4.NavigableString):
                        return None
                    return Text(text=" ")

            return Text(text=str(element).strip())

        cls = self.mapping.get(element.name, IgnoredOperation)
github math2001 / MarkdownLivePreview / markdown2html.py View on Github external
        text=lambda text: isinstance(text, bs4.Comment)
    ):
github zjuchenyuan / EasyLogin / EasyLogin.py View on Github external
"""
        Get all text in HTML, skip script and comment
        :param target: the BeatuifulSoup object, default self.b
        :param ignore_pureascii_words: if set True, only return words that contains Chinese charaters (may be useful for English version website)
        :return: list of str
        """
        if target is None:
            target = self.b
        from bs4 import Comment
        from bs4.element import NavigableString,Doctype
        result = []
        for descendant in target.descendants:
            if not isinstance(descendant, NavigableString) \
                    or isinstance(descendant,Doctype) \
                    or descendant.parent.name in ["script", "style"] \
                    or isinstance(descendant, Comment) \
                    or "none" in descendant.parent.get("style","")\
                    or "font-size:0px" in descendant.parent.get("style",""):
                continue
            data = descendant.strip()
            if len(data) > 0:
                if not ignore_pureascii_words or any([ord(i)>127 for i in data]):
                    if PY2:
                        result.append(data.encode('utf-8'))
                    else:
                        result.append(data)
        return result
github HurricaneLabs / machinae / src / machinae / sites / html.py View on Github external
            for comment in soup.find_all(text=lambda _: isinstance(_, Comment)):
                comment.extract()
github cobrateam / django-htmlmin / htmlmin / minify.py View on Github external
        f = lambda text: isinstance(text, bs4.Comment) and not \
            cond_regex.match(text.output_ready())
        [comment.extract() for comment in soup.findAll(text=f)]
github secdec / adapt / src / owasp_suite.py View on Github external
		comments = soup.findAll(text=lambda text:isinstance(text, Comment))
		return comments
github Codrspace / codrspace / apps / codrspace / utils.py View on Github external
    comments = soup.findAll(text=lambda text: isinstance(text, Comment))
    for comment in comments:
github WolverineSportsAnalytics / basketball / new_performance.py View on Github external
	soup.findAll(text=lambda text:isinstance(text, Comment))
	comments = soup.findAll(text=lambda text:isinstance(text, Comment))