| 11 | |
| 12 | |
| 13 | class TableTree(Tree): |
| 14 | def __init__(self, tag, colspan=None, rowspan=None, content=None, *children): |
| 15 | self.tag = tag |
| 16 | self.colspan = colspan |
| 17 | self.rowspan = rowspan |
| 18 | self.content = content |
| 19 | self.children = list(children) |
| 20 | |
| 21 | def bracket(self): |
| 22 | """Show tree using brackets notation""" |
| 23 | if self.tag == 'td': |
| 24 | result = '"tag": %s, "colspan": %d, "rowspan": %d, "text": %s' % \ |
| 25 | (self.tag, self.colspan, self.rowspan, self.content) |
| 26 | else: |
| 27 | result = '"tag": %s' % self.tag |
| 28 | for child in self.children: |
| 29 | result += child.bracket() |
| 30 | return "{{{}}}".format(result) |
| 31 | |
| 32 | |
| 33 | class CustomConfig(Config): |