comparison MoinMoin/formatter/__init__.py @ 2779:c9dd12befda7

wiki parser: match everything looking like a macro and either execute it (macro imports ok) or render the macro markup as text (macro import fails, error msg is in title). This makes scan_rules independent of wiki, so we can move all re.compile time to Parser class (doing it only once on module import time).
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 28 Aug 2007 13:43:11 +0200
parents 3a6a25169f55
children d2e9afd64276
comparison
equal deleted inserted replaced
2778:c8dd346f146e 2779:c9dd12befda7
302 def table_cell(self, on, attrs={}, **kw): 302 def table_cell(self, on, attrs={}, **kw):
303 raise NotImplementedError 303 raise NotImplementedError
304 304
305 # Dynamic stuff / Plugins ############################################ 305 # Dynamic stuff / Plugins ############################################
306 306
307 def macro(self, macro_obj, name, args): 307 def macro(self, macro_obj, name, args, markup=None):
308 # call the macro 308 # call the macro
309 return macro_obj.execute(name, args) 309 try:
310 310 return macro_obj.execute(name, args)
311 except ImportError, err:
312 errmsg = unicode(err)
313 if markup:
314 errmsg = wikiutil.escape(errmsg)
315 return (self.span(1, title=errmsg) +
316 self.text(markup) +
317 self.span(0))
318 else:
319 return self.text(errmsg)
311 def _get_bang_args(self, line): 320 def _get_bang_args(self, line):
312 if line.startswith('#!'): 321 if line.startswith('#!'):
313 try: 322 try:
314 name, args = line[2:].split(None, 1) 323 name, args = line[2:].split(None, 1)
315 except ValueError: 324 except ValueError: