def is_equation(text):
    """test if a piece of text is a latex equation, by how it is wrapped"""
    text = text.strip()

    if any(
        [
            text.startswith("\\begin{{{0}}}".format(env))
            and text.endswith("\\end{{{0}}}".format(env))
            for env in [
                "equation",
                "split",
                "equation*",
                "align",
                "align*",
                "multline",
                "multline*",
                "gather",
                "gather*",
            ]
        ]
    ):
        return True
    elif text.startswith("$") and text.endswith("$"):
        return True
    else:
        return False