How to highlight source code in MediaWiki

From Collectivesolver

Jump to: navigation, search

To highlight Source Code in MediaWiki follow the steps:

1. Download the last revision of the files SyntaxHighlight_GeSHi.class.php , SyntaxHighlight_GeSHi.i18n.php and SyntaxHighlight_GeSHi.php from WikiMedia SyntaxHighlight

2. Create directory 'SyntaxHighlight_GeSHi' under extensions/SyntaxHighlight_GeSHi

3. Copy the files to into the extensions/SyntaxHighlight_GeSHi directory.

4. Download the zip file GeSHi 1.0.8.4 (or newer version) form SourceForge GeSHi

5. Create directory 'geshi' under extensions/SyntaxHighlight_GeSHi/geshi

6. Open the zip file GeSHi and copy the file geshi.php into extensions/SyntaxHighlight_GeSHi/geshi

7. Create sub-directory 'geshi' under extensions/SyntaxHighlight_GeSHi/geshi/geshi

8. Copy the diertory 'geshi' with the programming languages files (like cpp.php) into extensions/SyntaxHighlight_GeSHi/geshi/geshi

9. Add the code line 'require_once("extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php");' to LocalSettings.php (as last line)

That's it - should work.

if you like for example to use c# code use the syntax:

<source lang="csharp">
...c-sharp source code (copy and paste from visual studio)
</source>

The real example:

// Hello World in Microsoft C# ("C-Sharp").
 
using System;
 
class HelloWorld
{
    public static int Main(String[] args)
    {
        Console.WriteLine("Hello, World!");
        return 0;
    }
}


You can use all the programming and script languages. Look at the extensions/SyntaxHighlight_GeSHi/geshi/geshi directory to see the support languages.

For more information visit MediaWiki Syntax Highlight GeSHi

Personal tools
Sponsor
Best 2009 Web Hosting