Showing posts with label patch. Show all posts
Showing posts with label patch. Show all posts

Wednesday, September 17, 2008

Change the Math button

Change the Math button in editor (standard Edit Toolbar) to produce <tex> and </tex> tags, instead of <math> and </math>

<math> tag support is like small hack, so I prefer to give users <tex> tag and save <math> tag for compatibility with Wikipedia standards.

Find into WIKI_HOME/includes/EditPage.php
array(
'image' => $wgLang->getImageFile('button-math'),
'id' => 'mw-editbutton-math',
'open' => "<math>",
'close' => "</math>",
'sample' => wfMsg('math_sample'),
'tip' => wfMsg('math_tip'),
'key' => 'C'
),


and replace it with
array(
'image' => $wgLang->getImageFile('button-math'),
'id' => 'mw-editbutton-math',
'open' => "<tex<",
'close' => "</tex>",
'sample' => wfMsg('math_sample'),
'tip' => wfMsg('math_tip'),
'key' => 'C'
),


See also http://www.mediawiki.org/wiki/Mimetex_alternative

It's possible to change MediaWiki system messges like math_sample or math_tip. List of messages is here http://WIKI_HOST/index.php5/Special:AllMessages
To change messages see files in WIKI_HOME/languages/messages (find files for your language).

Adding math tag support

Adding <math> tag support (without Latex installing).
The basic recipe is here: http://www.mediawiki.org/wiki/LaTeX_on_a_shared_host

  1. Find WIKI_HOME/includes/Math.php
  2. Backup it!
  3. Find public static function renderMath($tex, $params=array())
  4. Change function body to

public static function renderMath( $tex, $params=array() ) {
return '<img class="tex" src="/cgi-bin/mimetex.cgi?' . rawurlencode($tex) . '" alt="TeX: ' . rawurlencode($tex) . '">';
}


src="/cgi-bin/mimetex.cgi... because I've added mimetex.cgi into my cgi-bin directory. See also http://avbwiki.blogspot.com/2008/09/enable-tex.html