How to Setup Syntax Highlighting in MediaWiki

Steps for setting up GeSHi (Generic Syntax Highlighter) on MediaWiki:

  1. Download GeSHi (Generic Syntax Highlighter).
  2. Upload geshi.php and the geshi folder to your MediaWiki extensions folder.
  3. Create GeSHiHighlight.php using this source code.
  4. Copy the following line to your LocalSettings.php file.
    include("extensions/GeSHiHighlight.php");
  5. Add code to a MediaWiki page using <pre> tags.
    <php><?php echo "Hello World!"; ?></php>
    

More information about GeSHI can be found at http://qbnz.com/highlighter/.

Edit: Oops. I had posted the last step with <pre> tags instead of <php>. I’ve fixed it now. Thanks override!

  • June 27, 2008 at 11:50 pm override

    No, its not like that..
    To get the real syntax highlighting working should use:

    The way you have posted will just preformat text.

  • June 27, 2008 at 11:54 pm override

    ok , my comments got hidden:: as i said you should use the following code:

  • June 28, 2008 at 12:41 am override

    ok, it happened again, it sucks i cannot see a preview before posting, anyway , instead of “” you have to use “” with its respective “” to close the block.

    cheers

  • February 4, 2009 at 3:26 pm Rogan Creswick

    I still can’t believe how many people are using that chunk of php! :)

    Heres a more up-to-date source for the highlight extension:

    http://www.mediawiki.org/wiki/Extension:GeSHiHighlight

    (The version on intel-research is quite old, has my old email address, and there are some bugs/features that have been worked out — mostly by other people — I’m really not a php programmer, so there were a number of improvements.)

🎲