'Check for text in column margins and text overflow in the last column.
Raise TableMarkupError if anything but whitespace is in column margins.
Adjust the end value for the last column if there is text overflow.'

def check_columns(self, lines, first_line, columns):

    columns.append((sys.maxint, None))
    lastcol = (len(columns) - 2)
    for i in range((len(columns) - 1)):
        (start, end) = columns[i]
        nextstart = columns[(i + 1)][0]
        offset = 0
        for line in lines:
            if ((i == lastcol) and line[end:].strip()):
                text = line[start:].rstrip()
                new_end = (start + len(text))
                columns[i] = (start, new_end)
                (main_start, main_end) = self.columns[(-1)]
                if (new_end > main_end):
                    self.columns[(-1)] = (main_start, new_end)
            elif line[end:nextstart].strip():
                raise TableMarkupError(('Text    in    column    margin    at    line    offset    %s.' % (first_line + offset)))
            offset += 1
    columns.pop()
