def trim_non_repeat_barlines(annotation: str) -> str:
    """Removes all leading and trailing barlines (that are not repeat barlines)"""
    tokens = annotation.split()

    # leading
    while len(tokens) > 0 and tokens[0] == "|":
        del tokens[0]

    # trailing
    while len(tokens) > 0 and tokens[-1] == "|":
        del tokens[-1]

    return " ".join(tokens)