3 This plugin adds the <tex>...</tex> tags which allow you to
4 integrate formulas into wiki pages, if you have the MimeTeX
5 package (from John Forkosh) installed. You can get it from
6 [http://www.forkosh.com/mimetex.html] (source or as binary)
8 The original idea and implementation of this plugin was done by
9 Francois Vanderseypen <illumineo*users·sf·net> as you can see at
10 [http://netron.sourceforge.net/ewiki/netron.php?id=MimeTeX]
12 <tex> \aleph = \bigsum_{\alpha,\beta}\Bigint_{0}^{\infty}\:\Gamma_{\alpha\beta}(x)\,dx </tex>
15 define("MIMETEX_BIN", "mimetex");
16 # the actual mimetex utility (on poorly configured UNIX boxes you would
17 # have to give the full path name here)
19 define("MIMETEX_DIR", "/home/www/user28494/htdocs/ewiki/var/mimetex/");
20 # where generated images are thrown in (world-writeable!), you could
21 # use "/tmp" if _INLINE was ok for your users
23 define("MIMETEX_PATH", "/ewiki/var/mimetex/");
24 # where to access the generated images then (prefix for the <img> URLs)
26 define("MIMETEX_INLINE", 0);
27 # if you'd instead like data: URIs for images (does not work with IE <7)
30 $ewiki_plugins["format_block"]["tex"]= array("mimetex_format_block");
31 $ewiki_config["format_block"]["tex"] = array("<tex>", "</tex>", false, 0x0410);
34 function mimetex_format_block(&$str, &$in, &$iii, &$s, $btype) {
35 $str = mimetex_generate($str);
40 calls mimetex to create image or returns link to cached file
42 function mimetex_generate($formula) {
44 $formula = preg_replace("/[\s]+/", "", $formula);
45 $filename = md5($formula).".gif";
46 $fullname = MIMETEX_DIR."/$filename";
49 if (is_file($fullname)) {
50 $url = MIMETEX_PATH."/$filename";
53 $cmd = MIMETEX_BIN . " -e $fullname '" . escapeshellarg($formula) . "'";
54 system($cmd, $status);
56 $url = MIMETEX_PATH."/$filename";
62 $url = "data:image/gif;base64," . base64_encode(implode("", file($fullname)));
64 return('<img src="'.$url.'" alt="'.htmlentities($formula).'" align="absmiddle" />');
67 return("[MimeTex could not convert formula \"$formula\".]");