1.1 --- a/moinformat/tree.py Tue Dec 12 21:08:53 2017 +0100
1.2 +++ b/moinformat/tree.py Tue Dec 12 22:53:20 2017 +0100
1.3 @@ -19,6 +19,8 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 +from moinformat.serialisers import serialisers
1.8 +
1.9 class Container:
1.10
1.11 "A container of document nodes."
1.12 @@ -129,7 +131,13 @@
1.13
1.14 def to_string(self, out):
1.15 out.start_region(self.level, self.indent, self.type)
1.16 - self._to_string(out)
1.17 +
1.18 + # Obtain a serialiser for the region and serialise.
1.19 +
1.20 + region_out = serialisers.get(self.type)
1.21 + region_out = region_out and region_out(out.out) or out
1.22 + self._to_string(region_out)
1.23 +
1.24 out.end_region(self.level, self.indent, self.type)
1.25
1.26