def METHOD_NAME(text, strip_newlines=False, parse_html=False):
    if parse_html:
        soup = BeautifulSoup(text, features="html.parser")
        text = soup.get_text()
    # remove non-breaking spaces and separators
    text = text.replace("\xa0", " ").replace("\x1f", "")
    # remove nil bytes and tabs
    text = text.replace("\u0000", " ").replace("\u200b", " ").replace("\t", " ")
    if strip_newlines:
        text = text.replace("\r", " ").replace("\n", " ")
    # remove consecutive whitespaces
    return re.sub(r"\s\s+", " ", text, re.U).strip()