Syntax Highlighter and Code Colorizer for Mediawiki

Easily highlight syntax in MediaWiki!

Contents

Overview

This is a MediaWiki Extension for syntax highlighting. It is simple and probably one of the best syntax highlighters in the market. This plugin integrates Alex Gorbatchev’s Syntax Highlighter Tool : Alex’s Site. Full Support for :

  • Bash/shell
  • C#
  • C++
  • CSS
  • Delphi
  • Diff
  • Groovy
  • JavaScript
  • Java
  • Perl
  • PHP
  • Plain Text
  • Python
  • Ruby
  • Scala
  • SQL
  • Visual Basic
  • XML

Download

Download and unzip in your /extensions MediaWiki folder:
ZIP: syntax-highlighter-code-colorizer.zip for MediaWiki

Installation

  1. Unzip the Syntax Highlighting Extension file in your MediaWiki “extensions/” Folder
  2. in your LocalSettings.php add the line =
    
    require_once("extensions/syntax-highlighter-code-colorizer/syntax-highlighter-mediawiki.php");
    

Usage

Just surround your code like this:

<pre class="brush:[code-alias]"> …Your Code Here </pre>

replace the "[code-alias]" segment with the type of code you have. See all the available brush aliases. For Example, PHP would be like this:

<pre class="brush:php"> …Your PHP Code Here </pre>

Examples

C#

// Hello1.cs
public class Hello1
{
   public static void Main()
   {
      System.Console.WriteLine("Hello, World!");
   }
}

Java

class Dog
{
  public Dog(String aType)
  {
     System.out.println("I am a Dog");
  }
}
public class MainClass
{
  public static void main(String[] a)
  {
    Dog d = new Dog("a");
    Class objectType = d.getClass();
    System.out.println(objectType.getName());
  }
}

Bash / Shell

/usr/bin/svnadmin hotcopy /path/to/svn/repository /path/to/destination
2.
3.tar cvf /path/to/backup/svnbackup-`date +%Y-%m-%d`.tar /path/to/destination/*
4.
5./usr/local/bin/7z a -tbzip2 -v2g svnbackup-`date +%Y-%m-%d`.tar.bz2 /path/to/backup/svnbackup-`date +%Y-%m-%d`.tar

More Details

The Syntax Highlighter Plugin has more configurable options. Go to = http://alexgorbatchev.com/wiki/SyntaxHighlighter

Tags: , ,

7 Responses to “Syntax Highlighter and Code Colorizer for Mediawiki”

  1. Syntax Highlighter and Code Colorizer for Mediawiki : The Last Engine on April 28th, 2009 5:40 pm
  2. hockeyaddicts.com on June 1st, 2009 12:33 am

    Awesome, I’m using this now!

  3. Le blog de Bruno Caruso » Comment utiliser la coloration syntaxique sur MediaWiki ? on June 21st, 2009 3:58 pm

    [...] Mon Wiki local comporte plusieurs rubriques dont la majorité des pages sont des tutoriaux et des prises de notes liés à du code informatique (langage Action Script 3, PHP5, HTML, Java, CSS, XML, etc..). Mais malheureusement MediaWiki ne gère pas la coloration syntaxique nécessaire pour se repérer dans des longues séries de code. Pour cela j’utilise l’extension Syntax Highlighter Code Colorizer for Mediawiki. [...]

  4. Martin Farias on August 20th, 2009 8:37 pm

    what are the requirements?

    I did all but not found.

  5. El Huequito » Blog Archive » [Pedido] Información sobre Mediawiki on August 31st, 2009 9:48 am

    [...] Highlighter and Code Colorizer. Coloreador de código (para cuando usamos lenguajes de [...]

  6. Stanley on November 28th, 2009 2:19 pm

    Could I overwrite all tags to automatically have syntax highlighting?

  7. Stanley on November 28th, 2009 7:31 pm

    For anyone who had the same question as I, I wrote an extension to look up the category and switch through the possible values then replace the pre tag with the corresponding language.

Leave a Reply