1 """
2 See the latex parser, this is just a thin wrapper around it.
3 """
4
5 from MoinMoin import wikiutil
6 import re
7
8 Dependencies = []
9
10 splitre = re.compile(r'([^\\])%')
11
12 class latex:
13 def __init__(self, macro, args):
14 self.macro = macro
15 self.formatter = macro.formatter
16 self.text = args
17
18 def renderInPage(self):
19
20 if self.macro.request.mode_getpagelinks:
21 return ''
22
23 if self.text is None:
24 return ''
25
26
27
28 L = wikiutil.importPlugin(self.macro.cfg, 'parser', 'latex', 'Parser')
29 if L is None:
30 return self.formatter.text("<<please install the latex parser>>")
31 l = L('', self.macro.request)
32 tmp = splitre.split(self.text, 1)
33 if len(tmp) == 3:
34 prologue,p2,tex=tmp
35 prologue += p2
36 else:
37 prologue = ''
38 tex = tmp[0]
39 return l.get(self.formatter, tex, prologue)
40
41
42 def execute(macro, args):
43 return latex(macro, args).renderInPage()