""" inline_latex is a parser that allows regular moin moin wiki syntax, but also latex style inline formulas like $...$ and latex style paragraph formulas like $$...$$. Note that in the latter case, you are (unlike in latex) limited to a single line. If you absolutely need multiple lines, use the parser directly. Copyright 2005-2008 Johannes Berg <johannes@sipsolutions.net> Released under GPLv2. """ import re from MoinMoin.parser import text_moin_wiki from MoinMoin import wikiutil class Parser(text_moin_wiki.Parser): def __init__(self, raw, request, **kw): self.scan_rules += r'|(?P<latex_formula>\$[^$].*?(?<!\\)\$)' self.scan_rules += r'|(?P<latex_formula_para>\$\$.*?(?<!\\)\$\$)' self.scan_re = re.compile(self.scan_rules, re.UNICODE|re.VERBOSE) text_moin_wiki.Parser.__init__(self, raw, request, **kw) _latex_plugin = None def _aquire_latex_plugin(self): if self._latex_plugin is None: self._latex_plugin = wikiutil.importPlugin(self.cfg, 'parser', 'latex', 'Parser') def _latex_formula_repl(self, text, groups): self._aquire_latex_plugin() if self._latex_plugin is None: return self.formatter.text("<<please install the latex parser>>") return self._latex_plugin('', self.request).get(self.formatter, text, '') def _latex_formula_para_repl(self, text, groups): self._aquire_latex_plugin() if self._latex_plugin is None: return self.formatter.text("<<please install the latex parser>>") return self.formatter.paragraph(1) + \ self._latex_plugin('', self.request).get(self.formatter, text, '') + \ self.formatter.paragraph(0)