'Parse a table block and build table.'

def run(self, parent, blocks):

    block = blocks.pop(0).split('\n')
    header = block[:2]
    rows = block[2:]
    border = False
    if header[0].startswith('|'):
        border = True
    align = []
    for c in self._split_row(header[1], border):
        if (c.startswith(':') and c.endswith(':')):
            align.append('center')
        elif c.startswith(':'):
            align.append('left')
        elif c.endswith(':'):
            align.append('right')
        else:
            align.append(None)
    table = etree.SubElement(parent, 'table')
    thead = etree.SubElement(table, 'thead')
    self._build_row(header[0], thead, align, border)
    tbody = etree.SubElement(table, 'tbody')
    for row in rows:
        self._build_row(row, tbody, align, border)
