'Given a list of document lines starting with a list item,
finds the end of the list, breaks it up, and recursively
processes each list item and the remainder of the text file.
Keyword arguments:
* parentElem: A ElementTree element to which the content will be added
* lines: a list of lines
* inList: a level
Returns: None'

def __processList(self, parentElem, lines, inList, listexpr, tag):

    ul = etree.SubElement(parentElem, tag)
    looseList = 0
    items = []
    item = (-1)
    i = 0
    for line in lines:
        loose = 0
        if (not line.strip()):
            i += 1
            loose = 1
            for j in range(i, len(lines)):
                if lines[j].strip():
                    next = lines[j]
                    break
            else:
                break
            if (CORE_RE[listexpr].match(next) or CORE_RE['tabbed'].match(next)):
                items[item].append(line.strip())
                looseList = (loose or looseList)
                continue
            else:
                break
        for expr in ['ul', 'ol', 'tabbed']:
            m = CORE_RE[expr].match(line)
            if m:
                if (expr in ['ul', 'ol']):
                    items.append([m.group(1)])
                    item += 1
                elif (expr == 'tabbed'):
                    items[item].append(m.group(4))
                i += 1
                break
        else:
            items[item].append(line)
            i += 1
    else:
        i += 1
    for item in items:
        li = etree.SubElement(ul, 'li')
        self.parseChunk(li, item, (inList + 1), looseList=looseList)
    self.parseChunk(parentElem, lines[i:], inList)
