1.1 --- a/moinformat/tree/moin.py Tue Jul 24 12:58:58 2018 +0200
1.2 +++ b/moinformat/tree/moin.py Tue Jul 24 15:43:20 2018 +0200
1.3 @@ -138,10 +138,16 @@
1.4 def to_string(self, out):
1.5 out.start_region(self.level, self.indent, self.type, self.extra)
1.6
1.7 - # Obtain a serialiser for the region, if appropriate.
1.8 + # Obtain a serialiser class for the region from the same format family.
1.9 +
1.10 + serialiser_name = "%s.%s" % (out.format, self.type)
1.11 + serialiser_cls = out.formats and out.formats.get(serialiser_name)
1.12
1.13 - serialiser = out.formats and out.formats.get(self.type)
1.14 - region_out = serialiser and serialiser(out.out, out.formats) or out
1.15 + # Retain the same serialiser if no appropriate serialiser could be
1.16 + # obtained.
1.17 +
1.18 + region_out = serialiser_cls and serialiser_cls(out.out, out.formats) \
1.19 + or out
1.20
1.21 # Serialise the region.
1.22