def automata_line(state, line):
    """
    Automata parsing knowledges.
    0: waiting for knowledge block
    1: seen the heading of a knowledge block
    2: we are in a knowledge block
    """
    if state == 0 and "Undefined knowledges" in line:
        return 1, None
    elif state == 1 and "************************" in line:
        return 2, None
    elif (state == 2 or state == 0) and "************************" in line:
        return 0, None
    elif state == 2 and "| " in line:
        s = (line.split("| ", 1)[1]).split("\n", 1)[0]
        return 2, s
    else:
        return state, None