From a7759d6974de9e23ecc71bf9e741b7beeca5bab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 16 Sep 2012 23:51:11 +0200 Subject: [PATCH] parse few macros --- text_dokuwiki.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/text_dokuwiki.py b/text_dokuwiki.py index 4a0bec1..a8f52c4 100644 --- a/text_dokuwiki.py +++ b/text_dokuwiki.py @@ -11,6 +11,7 @@ from xml.sax import saxutils from MoinMoin.formatter.base import FormatterBase from MoinMoin import config from MoinMoin.Page import Page +from types import * # TODO: let base class MoinMoin/formatter/base.py handle not implemented methods @@ -246,3 +247,23 @@ class Formatter(FormatterBase): def code_token(self, on, tok_type): # not supported return '' + + def macro(self, macro_obj, name, args): + def email(args): + mail = args.replace(' AT ', '@') + mail = mail.replace(' DOT ', '.') + return '[[mailto:%s|%s]]' % (mail, args) + + try: + lookup = { + 'BR' : '\\\\', + 'MailTo' : email, + }[name] + except KeyError: + lookup = '/* UndefinedMacro: %s(%s) */' % (name, args) + + if type(lookup) == FunctionType: + text = lookup(args) + else: + text = lookup + return text