def parse_latex_cached()

in src/math_verify/parser.py [0:0]


def parse_latex_cached(latex: str):
    # First try to parse the latex as is
    try:
        return latex2sympy(
            latex,
            is_real=not should_treat_as_complex(latex),
            convert_degrees=False,
            normalization_config=None,
        )
    except Exception as e:
        # If that fails, try to parse just the last equation
        last_eq_latex = get_last_eq(latex)
        if last_eq_latex != latex:
            return latex2sympy(
                last_eq_latex,
                is_real=not should_treat_as_complex(last_eq_latex),
                convert_degrees=False,
                normalization_config=None,
            )
        else:
            raise e