def visit_moinpage_table(self, elem): attrib = Attributes(elem).convert() ret = html.table(attrib=attrib) for idx, item in enumerate(elem): tag = None if item.tag.uri == moin_page: if len(elem) > 1 and item.tag.name == 'table-body': # moinwiki_in converts "||header||\n===\n||body||\n===\n||footer||" into multiple table-body's if idx == 0: # make first table-body into header tag = html.thead elif len(elem) > 2 and idx == len(elem) - 1: # make last table-body into footer tag = html.tfoot else: tag = html.tbody elif item.tag.name == 'table-body': tag = html.tbody elif item.tag.name == 'table-header': tag = html.thead elif item.tag.name == 'table-footer': tag = html.tfoot elif item.tag.uri == html and \ item.tag.name in ('tbody', 'thead', 'tfoot'): tag = item.tag if tag is not None: ret.append(self.new_copy(tag, item)) return ret
def visit_moinpage_table(self, elem): attrib = Attributes(elem).convert() ret = html.table(attrib=attrib) caption = 1 if elem[0].tag.name == 'caption' else 0 for idx, item in enumerate(elem): tag = None if item.tag.uri == moin_page: if len(elem) > 1 + caption and html( 'class') in attrib and u'moin-wiki-table' in attrib[ html('class')]: # moinwiki tables require special handling because # moinwiki_in converts "||header||\n===\n||body||\n===\n||footer||" into multiple table-body's if idx == 0 + caption: # make first table-body after caption into header tag = html.thead elif len(elem) > 2 + caption and idx == len(elem) - 1: # make last table-body into footer tag = html.tfoot else: tag = html.caption if (caption and idx == 0) else html.tbody elif item.tag.name == 'table-body': tag = html.tbody elif item.tag.name == 'table-header': tag = html.thead elif item.tag.name == 'table-footer': tag = html.tfoot elif item.tag.name == 'caption': tag = html.caption elif item.tag.uri == html and \ item.tag.name in ('tbody', 'thead', 'tfoot'): tag = item.tag if tag is not None: ret.append(self.new_copy(tag, item)) return ret
def visit_moinpage_table(self, elem): attrib = Attributes(elem).convert() ret = html.table(attrib=attrib) for item in elem: tag = None if item.tag.uri == moin_page: if item.tag.name == "table-body": tag = html.tbody elif item.tag.name == "table-header": tag = html.thead elif item.tag.name == "table-footer": tag = html.tfoot elif item.tag.uri == html and item.tag.name in ("tbody", "thead", "tfoot"): tag = item.tag if tag is not None: ret.append(self.new_copy(tag, item)) return ret