'split a row of text with some code into a list of cells.'

def _split(self, row):

    elements = []
    pipes = []
    tics = []
    tic_points = []
    tic_region = []
    good_pipes = []
    for m in self.RE_CODE_PIPES.finditer(row):
        if m.group(2):
            tics.append((len(m.group(2)) - 1))
            tic_points.append((m.start(2), (m.end(2) - 1), 1))
        elif m.group(3):
            tics.append(len(m.group(3)))
            tic_points.append((m.start(3), (m.end(3) - 1), 0))
        elif m.group(5):
            pipes.append(m.start(5))
    pos = 0
    tic_len = len(tics)
    while (pos < tic_len):
        try:
            tic_size = (tics[pos] - tic_points[pos][2])
            if (tic_size == 0):
                raise ValueError
            index = (tics[(pos + 1):].index(tic_size) + 1)
            tic_region.append((tic_points[pos][0], tic_points[(pos + index)][1]))
            pos += (index + 1)
        except ValueError:
            pos += 1
    for pipe in pipes:
        throw_out = False
        for region in tic_region:
            if (pipe < region[0]):
                break
            elif (region[0] <= pipe <= region[1]):
                throw_out = True
                break
        if (not throw_out):
            good_pipes.append(pipe)
    pos = 0
    for pipe in good_pipes:
        elements.append(row[pos:pipe])
        pos = (pipe + 1)
    elements.append(row[pos:])
    return elements
