1.1 --- a/moinformat/macros/br.py Tue Jul 31 00:00:49 2018 +0200
1.2 +++ b/moinformat/macros/br.py Tue Jul 31 00:07:22 2018 +0200
1.3 @@ -32,16 +32,10 @@
1.4
1.5 "Evaluate the macro, producing a line break node."
1.6
1.7 - macro = self.node
1.8 - nodes = macro.parent.nodes
1.9 -
1.10 # Replace the macro node with the line break.
1.11
1.12 - try:
1.13 - i = nodes.index(macro)
1.14 - nodes[i] = LineBreak()
1.15 - except ValueError:
1.16 - pass
1.17 + macro = self.node
1.18 + macro.parent.replace(macro, LineBreak())
1.19
1.20 macro = LineBreakMacro
1.21
2.1 --- a/moinformat/macros/toc.py Tue Jul 31 00:00:49 2018 +0200
2.2 +++ b/moinformat/macros/toc.py Tue Jul 31 00:07:22 2018 +0200
2.3 @@ -134,6 +134,7 @@
2.4 items.append(item)
2.5
2.6 # Replace the macro node's children with the top-level list.
2.7 + # The macro cannot be replaced because it will be appearing inline.
2.8
2.9 self.node.nodes = [lists[0]]
2.10
3.1 --- a/moinformat/tree/moin.py Tue Jul 31 00:00:49 2018 +0200
3.2 +++ b/moinformat/tree/moin.py Tue Jul 31 00:07:22 2018 +0200
3.3 @@ -106,6 +106,13 @@
3.4 if text:
3.5 self.append(text)
3.6
3.7 + def replace(self, old, new):
3.8 +
3.9 + "Replace 'old' with 'new' in the children."
3.10 +
3.11 + i = self.nodes.index(old)
3.12 + self.nodes[i] = new
3.13 +
3.14 def __str__(self):
3.15 return self.prettyprint()
3.16