def _normalize_string(text):
    """Trims the text, removes all the spaces from text and replaces every sequence of lines with a single line.

    Args:
        text (str): The schema definition.

    Returns:
        str: The normalized text.
    """
    text = text.strip()
    result = ""
    whitespaces = [" ", "\t"]
    in_comment = False
    in_string = False
    string_char = None
    for c in text:
        if c == "#":
            in_comment = True
        if c == "\n":
            in_comment = False
        if c == '"' or c == "'":
            if in_string and c == string_char:
                in_string = False
            elif not in_string and not in_comment:
                in_string = True
                string_char = c

        if not in_comment and not in_string and c in whitespaces:
            continue
        if c == "\n" and result.endswith("\n"):
            continue
        result += c
    return result