(self, index=0, width=0, rowspan=None)
| 69 | return total |
| 70 | |
| 71 | def scan_format(self, index=0, width=0, rowspan=None): |
| 72 | if rowspan is None: |
| 73 | rowspan = {} |
| 74 | |
| 75 | format_str = '' |
| 76 | |
| 77 | expand_char = 'x' if platform.system() != 'Darwin' else '' |
| 78 | |
| 79 | if self.name in ['th', 'td']: |
| 80 | extend = ((width == 3 and index == 1) or |
| 81 | (width != 3 and width < 5 and index == width - 1)) |
| 82 | |
| 83 | if self.name == 'th': |
| 84 | format_str += 'c%s ' % (expand_char if extend else '') |
| 85 | else: |
| 86 | format_str += 'l%s ' % (expand_char if extend else '') |
| 87 | |
| 88 | if 'colspan' in self.attr: |
| 89 | for i in range(int(self.attr['colspan']) - 1): |
| 90 | format_str += 's ' |
| 91 | |
| 92 | if 'rowspan' in self.attr and int(self.attr['rowspan']) > 1: |
| 93 | rowspan[index] = int(self.attr['rowspan']) - 1 |
| 94 | |
| 95 | if self.name == 'tr' and len(rowspan) > 0: |
| 96 | ci = 0 |
| 97 | for i in range(width): |
| 98 | if i in rowspan: |
| 99 | format_str += '^ ' |
| 100 | if rowspan[i] == 1: |
| 101 | del rowspan[i] |
| 102 | else: |
| 103 | rowspan[i] -= 1 |
| 104 | else: |
| 105 | # There is a row span, but the current number of column is |
| 106 | # not enough. Pad empty node when this happens. |
| 107 | if ci >= len(self.children): |
| 108 | self.children.append(Node(self, 'td', '', '')) |
| 109 | |
| 110 | format_str += self.children[ci].scan_format(i, width, |
| 111 | rowspan) |
| 112 | ci += 1 |
| 113 | else: |
| 114 | if self.children and self.children[0].name == 'tr': |
| 115 | width = self.children[0].get_row_width() |
| 116 | |
| 117 | for i, c in enumerate(self.children): |
| 118 | format_str += c.scan_format(i, width, rowspan) |
| 119 | |
| 120 | if self.name == 'table': |
| 121 | format_str += '.\n' |
| 122 | elif self.name == 'tr': |
| 123 | format_str += '\n' |
| 124 | |
| 125 | return format_str |
| 126 | |
| 127 | def gen(self, fd, index=0, last=False, rowspan=None): |
| 128 | if rowspan is None: |
no test coverage detected