1.1 --- a/moinformat/tree/moin.py Mon Jul 30 17:18:52 2018 +0200
1.2 +++ b/moinformat/tree/moin.py Mon Jul 30 23:19:20 2018 +0200
1.3 @@ -40,12 +40,32 @@
1.4
1.5 add = append
1.6
1.7 - append_inline = append
1.8 + def append_inline(self, node):
1.9 +
1.10 + "Append 'node' inline within the appropriate container."
1.11 +
1.12 + n = self.append_point()
1.13 +
1.14 + # Redirect the addition if another container is to accept the node.
1.15 +
1.16 + if n is not self:
1.17 + n.append_inline(node)
1.18 +
1.19 + # Otherwise, append within this container.
1.20 +
1.21 + else:
1.22 + n.append(node)
1.23
1.24 def append_inline_many(self, nodes):
1.25 for node in nodes:
1.26 self.append_inline(node)
1.27
1.28 + def append_point(self):
1.29 +
1.30 + "Return the container to which inline nodes are added."
1.31 +
1.32 + return self
1.33 +
1.34 def empty(self):
1.35 return not self.nodes
1.36
1.37 @@ -117,11 +137,14 @@
1.38 else:
1.39 self.append(node)
1.40
1.41 - def append_inline(self, node):
1.42 + def append_point(self):
1.43 +
1.44 + "Return the container to which inline nodes are added."
1.45 +
1.46 if self.transparent:
1.47 - self.nodes[-1].append(node)
1.48 + return self.nodes[-1]
1.49 else:
1.50 - self.append(node)
1.51 + return self
1.52
1.53 def have_end(self, s):
1.54 return self.level and s.startswith("}") and self.level == len(s)
1.55 @@ -453,13 +476,14 @@
1.56
1.57 "Macro details."
1.58
1.59 - def __init__(self, name, args, nodes=None):
1.60 + def __init__(self, name, args, parent, nodes=None):
1.61 Container.__init__(self, nodes or [])
1.62 self.name = name
1.63 + self.parent = parent
1.64 self.args = args
1.65
1.66 def __repr__(self):
1.67 - return "Macro(%r, %r, %r)" % (self.name, self.args, self.nodes)
1.68 + return "Macro(%r, %r, %r, %r)" % (self.name, self.args, self.parent, self.nodes)
1.69
1.70 def prettyprint(self, indent=""):
1.71 l = ["%sMacro: name=%r args=%r" % (indent, self.name, self.args)]
1.72 @@ -549,6 +573,19 @@
1.73 def to_string(self, out):
1.74 out.break_()
1.75
1.76 +class LineBreak(Node):
1.77 +
1.78 + "A line break within a block."
1.79 +
1.80 + def __repr__(self):
1.81 + return "LineBreak()"
1.82 +
1.83 + def prettyprint(self, indent=""):
1.84 + return "%sLineBreak" % indent
1.85 +
1.86 + def to_string(self, out):
1.87 + out.linebreak()
1.88 +
1.89 class Rule(Node):
1.90
1.91 "A horizontal rule."