from typing import Optional
from typing import List


def parse_skip(line) -> Optional[List[int]]:
    """Returns None if the line is not a exdown-skip statement
    Otherwise returns the lines to skip (numbering starts at 1).
    The empty list indicates that the whole block must be skipped."""
    line = line.lstrip()
    searched = "exdown-skip"
    idx = line.find(searched)
    if idx < 0:
        return None
    suffix = line[idx + len(searched) :]
    skipped_lines = []
    for nb_line in suffix.lstrip().split(" "):  # Parse to the right of exdown-skip
        try:
            nb_line = int(nb_line)
            if nb_line < 1:
                raise Exception(
                    f"Line numbers in {searched} start at 1, but received {nb_line}"
                )
            skipped_lines.append(nb_line)
        except ValueError as _:
            break
    return skipped_lines