Imports initiaux
darcs-hash:20060416092713-72cb0-421d3cbb49699fce4971355f5dbbaa19091945e8.gz
This commit is contained in:
parent
0192d9e074
commit
1e7ce4861e
7 changed files with 1645 additions and 0 deletions
44
wiki/macro/latex.py
Normal file
44
wiki/macro/latex.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
#FORMAT python
|
||||
"""
|
||||
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()
|
Loading…
Add table
Add a link
Reference in a new issue