1.1 --- a/moinformat/parsers/moin.py Tue Jul 24 15:43:20 2018 +0200
1.2 +++ b/moinformat/parsers/moin.py Tue Jul 24 18:45:13 2018 +0200
1.3 @@ -36,11 +36,12 @@
1.4
1.5 "A wiki region parser."
1.6
1.7 - def __init__(self, formats=None):
1.8 + def __init__(self, formats=None, root=None):
1.9
1.10 """
1.11 Initialise the parser with any given 'formats' mapping from region type
1.12 - names to parser objects.
1.13 + names to parser objects. An optional 'root' indicates the document-level
1.14 + parser.
1.15 """
1.16
1.17 # Introduce this class as the default parser for the wiki format.
1.18 @@ -49,7 +50,11 @@
1.19 if formats:
1.20 default_formats.update(formats)
1.21
1.22 - ParserBase.__init__(self, default_formats)
1.23 + ParserBase.__init__(self, default_formats, root)
1.24 +
1.25 + # Record macro occurrences for later evaluation.
1.26 +
1.27 + self.macros = []
1.28
1.29 # Principal parser methods.
1.30
1.31 @@ -464,6 +469,10 @@
1.32 macro = Macro(name, arglist)
1.33 region.append_inline(macro)
1.34
1.35 + # Record the macro for later processing.
1.36 +
1.37 + self.root.macros.append(macro)
1.38 +
1.39
1.40
1.41 # Table attribute handlers.