00001
00002 """
00003 See the latex parser, this is just a thin wrapper around it.
00004 """
00005
00006 from MoinMoin import wikiutil
00007 import re
00008
00009 Dependencies = []
00010
00011 splitre = re.compile(r'([^\\])%')
00012
00013 class latex:
00014 def __init__(self, macro, args):
00015 self.macro = macro
00016 self.formatter = macro.formatter
00017 self.text = args
00018
00019 def renderInPage(self):
00020
00021 if self.macro.request.mode_getpagelinks:
00022 return ''
00023
00024 if self.text is None:
00025 return ''
00026
00027
00028
00029 L = wikiutil.importPlugin(self.macro.cfg, 'parser', 'latex', 'Parser')
00030 if L is None:
00031 return self.formatter.text("<<please install the latex parser>>")
00032 l = L('', self.macro.request)
00033 tmp = splitre.split(self.text, 1)
00034 if len(tmp) == 3:
00035 prologue,p2,tex=tmp
00036 prologue += p2
00037 else:
00038 prologue = ''
00039 tex = tmp[0]
00040 return l.get(self.formatter, tex, prologue)
00041
00042
00043 def execute(macro, args):
00044 return latex(macro, args).renderInPage()