Ajout de scripts manquants

darcs-hash:20090610100826-69ccb-32281005e3cc3d598d4b10a440fe9c29826e32a0.gz
This commit is contained in:
Grgoire Dtrez 2009-06-10 12:08:26 +02:00
parent 4f69918eba
commit c1d5e45ce1
3 changed files with 294 additions and 0 deletions

44
wiki/macro/Latex.py Normal file
View file

@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
"""
See the latex parser, this is just a thin wrapper around it.
"""
# Imports
from MoinMoin import wikiutil
import re
Dependencies = []
splitre = re.compile(r'([^\\])%')
class latex:
def __init__(self, macro, args):
self.macro = macro
self.formatter = macro.formatter
self.text = args
def renderInPage(self):
# return immediately if getting links for the current page
if self.macro.request.mode_getpagelinks:
return ''
if self.text is None: # macro call without parameters
return ''
# get an exception? for moin before 1.3.2 use the following line instead:
# L = wikiutil.importPlugin('parser', 'latex', 'Parser', self.macro.cfg.data_dir)
L = wikiutil.importPlugin(self.macro.cfg, 'parser', 'latex', 'Parser')
if L is None:
return self.formatter.text("<<please install the latex parser>>")
l = L('', self.macro.request)
tmp = splitre.split(self.text, 1)
if len(tmp) == 3:
prologue,p2,tex=tmp
prologue += p2
else:
prologue = ''
tex = tmp[0]
return l.get(self.formatter, tex, prologue)
def execute(macro, args):
return latex(macro, args).renderInPage()