(self, parent, blocks)
Parse a table block and build table.
Parse a table block and build table.
Parse a table block and build table .
def run(self, parent, blocks):
        """ Parse a table block and build table. """
        block = blocks.pop(0).split('\n')
        header = block[0].strip()
        seperator = block[1].strip()
        rows = block[2:]
        # Get format type (bordered by pipes or not)
        border = False
        if header.startswith('|'):
            border = True
        # Get alignment of columns
        align = []
        for c in self._split_row(seperator, 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)
        # Build table
        table = etree.SubElement(parent, 'table')
        thead = etree.SubElement(table, 'thead')
        self._build_row(header, thead, align, border)
        tbody = etree.SubElement(table, 'tbody')
        for row in rows:
            self._build_row(row.strip(), tbody, align, border)
def run ( self , parent , blocks ) : block = blocks . pop ( 0 ) . split ( '\n' ) header = block [ 0 ] . strip ( ) seperator = block [ 1 ] . strip ( ) rows = block [ 2 : ] # Get format type (bordered by pipes or not) border = False if header . startswith ( '|' ) : border = True # Get alignment of columns align = [ ] for c in self . _split_row ( seperator , 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 ) # Build table table = etree . SubElement ( parent , 'table' ) thead = etree . SubElement ( table , 'thead' ) self . _build_row ( header , thead , align , border ) tbody = etree . SubElement ( table , 'tbody' ) for row in rows : self . _build_row ( row . strip ( ) , tbody , align , border )