Extension:Mimetex alternative

From MediaWiki.org
(Redirected from Mimetex alternative)
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
Mimetex alternative
Release status: unmaintained
Description Allows for parsing mathematical expressions when the Extension:Math does not work.
License No license specified
Download No link
Translate the Mimetex alternative extension if it is available at translatewiki.net
Check usage and version matrix.

On some web hosting servers, especially shared hosting servers, LaTeX, ImageMagick, or Ghostwriter may not be installed. Using a program called Mimetex.cgi which was created by John Forkosh, a work around has been created.

You can view his site at http://www.forkosh.com/mimetex.html for a complete description of Mimetex.

How to use Mimetex on your own server[edit]

To install Mimetex on your own server, and integrate its functionality into Mediawiki you will need Mediawiki installed on a web server and Ftp access. If you have this much, follow the instructions below.

This installation will allow you to use <tex> and </tex> tags in your edit boxes. If you modify the EditPage.php file as shown below you can use the Math button included in Mediawiki to insert the proper tags.

Save the text below in a file called mimetex.php and install this file into your extensions folder.


$wgExtensionFunctions[] = "MimetexExtension";

function MimetexExtension() {
    global $wgParser;

    $wgParser->setHook( "tex", "render_Mimetex" );

* Renders $text in Mimetex
function render_Mimetex($input, $argv, $parser = null) {

  if (!$parser) $parser =& $GLOBALS['wgParser'];

  // $img_url is the url the mimetex will be sent to.
  // IMPORTANT!! The URL below should be the link to YOUR mimetex.cgi if possible
  $img_url = "http://www.forkosh.com/mimetex.cgi?".rawurlencode($input);
  // Sets the output of the tex tag using the url from above, and the input as
  // the Alt text.  It's important to note that there is no error output added yet.
  $output = "<img src=\"$img_url\" alt=\"LaTeX: " . htmlspecialchars($input) . "\" />";

  return $output;

and add the line:


to the end of your LocalSettings.php file in your root directory of your MediaWiki site.

You also change the Math button in your editor to give you <tex> and </tex> tags. You can customize the Edit Toolbar quite easily.

In the ...wiki/includes/ directory you will find a file called EditPage.php. Don't forget to make a copy before changing it, just in case (cp EditPage.php EditPage.php~).

Search for the following lines:

array(	'image'	=>'button_math.png',
	'open'	=>	"<math>",
	'close'	=>	"</math>",
	'sample'=>	wfMsg('math_sample'),
	'tip'	=>	wfMsg('math_tip'),
	'key'	=>	'C'

Replace with:

array(	'image'	=>'button_math.png',
	'open'	=>	"<tex>",
	'close'	=>	"</tex>",
	'sample'=>	wfMsg('math_sample'),
	'tip'	=>	wfMsg('math_tip'),
	'key'	=>	'C'

You should make sure your files have the correct permissions (read and execute, but not write). Also note that there is no error encoding included in this installation, but fortunately Mimetex.cgi will do that for you (if the code entered is not a LaTeX equation, a blank image will be presented).

To install Mimetex, either follow the instructions at www.forkosh.com/mimetex.html or download the appropriate Mimetex.cgi precompiled file from: http://www.forkosh.dreamhost.com/mimetex.exe/

Your version of Mimetex.cgi needs to be placed in the ../cgi-bin folder on your website, and needs to have the file permissions be 755 (everyone can read and execute the file and the user can write to it).

This extension was created by examining a module in Drupal called Drutex (which was originally authored by Daniel Gutekunst), although very little of the original code is the same. It also uses the sample code provided by Mediawiki for the purposes of creating extensions. It is meant to be covered under the GNU General Public License. The author of this extension is David Wees, July 1st, 2006.

See Also[edit]