changeset 2960:b9d8366bb31e

Creole parser: instantiate macro with Parser object, not Emitter
author Radomir Dopieralski <moindev@sheep.art.pl>
date Thu, 13 Dec 2007 10:37:17 +0100
parents fcfa07f447f5
children fa3e3d441dce
files MoinMoin/parser/text_creole.py
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/parser/text_creole.py	Sun Dec 09 22:40:44 2007 +0100
+++ b/MoinMoin/parser/text_creole.py	Thu Dec 13 10:37:17 2007 +0100
@@ -23,7 +23,8 @@
 
 import re
 import StringIO
-from MoinMoin import config, macro, wikiutil
+from MoinMoin import config, wikiutil
+from MoinMoin.macro import Macro
 from MoinMoin.support.python_compatibility import rsplit # Needed for python 2.3
 from _creole import Parser as CreoleParser
 
@@ -50,7 +51,7 @@
         """Create and call the true parser and emitter."""
 
         document = CreoleParser(self.raw).parse()
-        result = Emitter(document, formatter, self.request).emit()
+        result = Emitter(document, formatter, self.request, Macro(self)).emit()
         self.request.write(result)
 
 class Rules:
@@ -81,12 +82,12 @@
             Rules.page
         ]), re.X | re.U) # for addresses
 
-    def __init__(self, root, formatter, request):
+    def __init__(self, root, formatter, request, macro):
         self.root = root
         self.formatter = formatter
         self.request = request
         self.form = request.form
-        self.macro = None
+        self.macro = macro
 
     def get_text(self, node):
         """Try to emit whatever text is in the node."""
@@ -379,8 +380,6 @@
     def macro_emit(self, node):
         macro_name = node.content
         args = node.args
-        if self.macro is None:
-            self.macro = macro.Macro(self)
         try:
             return self.formatter.macro(self.macro, macro_name, args)
         except: