def METHOD_NAME(text, extended=True, *, ITALIC=r"\\f[I]\1\\f[]", REGULAR=r"\1"):
    text = text.replace("\\", "\\\\")
    # ``foo``
    repl = ITALIC if extended else REGULAR
    text = re.sub(r"``([^`]+)``", repl, text)
    # |foo|_
    text = re.sub(r"\|([^|]+)\|_*", ITALIC, text)
    # `foo <bar>`__
    text = re.sub(r"`([^`<]+) <[^>`]+>`_+", ITALIC, text)
    # `foo`_
    text = re.sub(r"`([^`]+)`_+", ITALIC, text)
    # `foo`
    text = re.sub(r"`([^`]+)`", REGULAR, text)
    # foo_
    text = re.sub(r"([A-Za-z0-9-]+)_+(?=\s)", ITALIC, text)
    # -------
    text = re.sub(r"---+", "", text)
    return text