Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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>
for comment in doc.find_all(text=lambda text: isinstance(text, Comment)):
comment.extract()
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)
text=lambda text: isinstance(text, bs4.Comment)
):
"""
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
for comment in soup.find_all(text=lambda _: isinstance(_, Comment)):
comment.extract()
f = lambda text: isinstance(text, bs4.Comment) and not \
cond_regex.match(text.output_ready())
[comment.extract() for comment in soup.findAll(text=f)]
comments = soup.findAll(text=lambda text:isinstance(text, Comment))
return comments
comments = soup.findAll(text=lambda text: isinstance(text, Comment))
for comment in comments:
soup.findAll(text=lambda text:isinstance(text, Comment))
comments = soup.findAll(text=lambda text:isinstance(text, Comment))