def METHOD_NAME(text, guess=True):
    """Returns the type of the given text ('lilypond, 'html', etc.).
    Checks the mode variable and guesses otherwise if guess is True.
    """
    mode = variables.variables(text).get("mode")
    if mode in ly.lex.modes:
        return mode
    if guess:
        return ly.lex.guessMode(text)