changeset 313:ba7dae2cfec0

macr.mathtran: initial version of a wrapper macro for the mathtrans parser
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 27 Nov 2008 17:09:08 +0100
parents 928d0324af65
children c1e0bb60a0c2
files data/plugin/macro/mathtran.py
diffstat 1 files changed, 30 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/plugin/macro/mathtran.py	Thu Nov 27 17:09:08 2008 +0100
@@ -0,0 +1,30 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - mathtran
+
+    This macro is used to call the mathtran parser,
+    it is just a thin wrapper around it.
+
+    @copyright: 2008 by MoinMoin:ReimarBauer
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from MoinMoin import wikiutil
+
+class mathtran:
+    def __init__(self, macro, args):
+        self.macro = macro
+        self.formatter = macro.formatter
+        self.args = args
+
+    def renderInPage(self):
+        mathtran_parser = wikiutil.importPlugin(self.macro.cfg, 'parser', 'text_x_mathtran', 'Parser')
+        if mathtran_parser is None:
+            return self.formatter.text("Please install the mathtran parser!")
+
+        ap = mathtran_parser(self.args, self.macro.request)
+        if ap.init_settings:
+            return ap.render(self.formatter)
+
+def execute(macro, args):
+    return mathtran(macro, args).renderInPage()