Open main menu

MediaWiki/Syntax highlighting

< MediaWiki
Revision as of 21:17, 3 June 2007 by Freephile (talk | contribs) (inital draft)

(diff) ← Older revision | Approved revision (diff) | Latest revision (diff) | Newer revision → (diff)

Writing good code follows good coding standards. On top of coding standards, syntax highlighting reveals the code making it easier to read (and learn).

There is a Generic Syntax Highlighter or GeSHi for short which is available as a Debian package (sudo apt-get install php-geshi). Adding a GeSHi Mediawiki extension to allows it to be used in this wiki.

Incorporating it into Mediawiki is just a matter of creating/configuring the extension and including it in LocalSettings.

Usage

There are two code tags that you can use:

  1. Simple Tag Format: <'language'>source code here</'language'>
  2. Advanced Tag Format: <code ['language'|list] [n] >source code here</code>


Tag Examples

- simple code tag
<php> echo "Hello World"; </php>


- advanced code tag
<code php> echo "Hello World"; </code>


- advanced code tag with line numbers
<code php n> echo "Hello World"; </code>


- default code tag
<code> echo "Hello World"; </code>


- display a list of supported languages
<code list></code>

Supported Languages

Documentation

See http://qbnz.com/highlighter/geshi-doc.html for the extensive documentation. GeSHi is used in a number of other software projects like

  • Dokuwiki - An advanced wiki engine
  • gtk.php.net - Their manual uses GeSHi for syntax highlighting
  • WordPress - A powerful blogging system*
  • PHP-Fusion - A constantly evovling CMS
  • SQL Manager - A Postgres DBAL
  • Mambo - A popular open source CMS
  • MediaWiki - A leader in Wikis*
  • TikiWiki - A megapowerful Wiki/CMS
  • TikiPro - Another powerful Wiki based on Tikiwiki
  • RWeb - A site-building tool

If you want to use it in OASIS projects besides this wiki, then start with the documentation.