def parse_sections(lines):
    """Parse the input document into sections, separated by blank lines.
    A list of lists is returned.  Each item is the list of lines for a section.
    """
    secid = 0
    section = []
    for line in lines:
        if not line.strip():
            secid += 1
            continue
        if len(section) == secid:
            section.append([line])
        else:
            section[secid].append(line)
    return [v for v in section if v]