1.1 --- a/moinformat/tree.py Tue May 02 16:39:30 2017 +0200
1.2 +++ b/moinformat/tree.py Wed May 03 00:32:46 2017 +0200
1.3 @@ -284,19 +284,41 @@
1.4 self._to_string(out)
1.5 out.end_listitem(self.indent, self.marker)
1.6
1.7 +class TableAttrs(Container):
1.8 +
1.9 + "A collection of table attributes."
1.10 +
1.11 + def __repr__(self):
1.12 + return "TableAttrs(%r)" % self.nodes
1.13 +
1.14 + def prettyprint(self, indent=""):
1.15 + l = ["%sTableAttrs:" % indent]
1.16 + return self._prettyprint(l, indent)
1.17 +
1.18 + def to_string(self, out):
1.19 + out.start_table_attrs()
1.20 + self._to_string(out)
1.21 + out.end_table_attrs()
1.22 +
1.23 class TableCell(Container):
1.24
1.25 "A table cell."
1.26
1.27 + def __init__(self, nodes, attrs=None):
1.28 + Container.__init__(self, nodes)
1.29 + self.attrs = attrs
1.30 +
1.31 def __repr__(self):
1.32 - return "TableCell(%r)" % self.nodes
1.33 + return "TableCell(%r, %f)" % (self.nodes, self.attrs)
1.34
1.35 def prettyprint(self, indent=""):
1.36 l = ["%sTableCell:" % indent]
1.37 + if self.attrs:
1.38 + l.append(self.attrs.prettyprint(indent + " "))
1.39 return self._prettyprint(l, indent)
1.40
1.41 def to_string(self, out):
1.42 - out.start_table_cell()
1.43 + out.start_table_cell(self.attrs)
1.44 self._to_string(out)
1.45 out.end_table_cell()
1.46
1.47 @@ -420,11 +442,29 @@
1.48 return "Rule(%d)" % self.length
1.49
1.50 def prettyprint(self, indent=""):
1.51 - return "%sRule: %d" % (indent, self.length)
1.52 + return "%sRule: length=%d" % (indent, self.length)
1.53
1.54 def to_string(self, out):
1.55 out.rule(self.length)
1.56
1.57 +class TableAttr(Node):
1.58 +
1.59 + "A table attribute."
1.60 +
1.61 + def __init__(self, name, value=None, concise=False):
1.62 + self.name = name
1.63 + self.value = value
1.64 + self.concise = concise
1.65 +
1.66 + def __repr__(self):
1.67 + return "TableAttr(%r, %r, %r)" % (self.name, self.value, self.concise)
1.68 +
1.69 + def prettyprint(self, indent=""):
1.70 + return "%sTableAttr: name=%r value=%r concise=%r" % (indent, self.name, self.value, self.concise)
1.71 +
1.72 + def to_string(self, out):
1.73 + out.table_attr(self.name, self.value, self.concise)
1.74 +
1.75 class Text(Node):
1.76
1.77 "A text node."