Commodore64 Reply #1, 5 years, 9 months ago
Hello,
this plugin allows you to render LaTeX code into your document contents, in a similar way as in Wikipedia.
Just wrap your LaTeX code in double dollars, like that: $\sum_{i=0}^n 2^i = 2^{n+1} - 1$.
But please note that:
Here is the plugin code:
this plugin allows you to render LaTeX code into your document contents, in a similar way as in Wikipedia.
Just wrap your LaTeX code in double dollars, like that: $\sum_{i=0}^n 2^i = 2^{n+1} - 1$.
But please note that:
-
[list]
- you must download and install the mimeTeX cgi program in your /cgi-bin directory. Obviously, you must have rights to do that. You can download the program here: http://www.forkosh.com/mimetex.html
- there is an issue with backslashes in MODx. Every backslash is ignored unless it is quoted with another backslash. Thus, you should double all the backslashes in your LaTeX, like that: $\\sum_{i=0}^n 2^i = 2^{n+1} - 1$. The issue is described in this thread: http://modxcms.com/forums/index.php/topic,4156.0.html. I fixed the problem with a hack of /manager/includes/document.parser.class.inc.php: search for stripslashes and replace the line where it occurs with
$replace[$i] = $value; and the need to double backslashes will be gone; however, I don't recommend this hack because I don't know what is the purpose of the stripslashes function call that I removed!
Here is the plugin code:
/** * mimeTeX Plugin 0.1 for MODx * by Luca Allulli, April 2006 * * Event: OnLoadWebDocument * * Download and install mimeTeX from http://www.forkosh.com/mimetex.html * * License: GNU GPL * */ //Begin configuration global $mimetexPath; $mimetexPath="/cgi-bin/mimetex.cgi"; //End configuration function replaceCodeMimetex($matches) { global $mimetexPath; return '<img src="'.$mimetexPath.'?'.$matches[1].'" align="middle" style="margin-bottom: 7px;" />'; } $e = &$modx->Event; switch ($e->name) { case "OnLoadWebDocument": $modx->documentObject['content']=preg_replace_callback("#\\$\\$(.*?)\\$\\$#s", "replaceCodeMimetex", $modx->documentObject['content']); break; default: // stop here break; }
Good to know that MODx 0.9.5 doesn't strip backslashes (I wonder why the old versions did).