GeSHi
The standard GeSHi MediaWiki extensions don't quite suit our purposes because our articles containing code are usually directly executed which means that we can't include GeSHi code tags. To get around this I've added a few extra lines after the GeSHi include to allow the tags to be added before parsing based on the article content or title as follows: <php-brief> include('extensions/geshi/GeSHiCodeTag.php'); $wgHooks['ParserBeforeStrip'][] = 'GeSHi'; function GeSHi(&$parser, &$text, &$strip_state) {
if (preg_match('/^<\\?/',$text)) $text = "<php>\n$text\n<GeSHi/php>"; if (preg_match('/^#!\\/usr\\/bin\\/perl/',$text)) $text = "<perl>\n$text\n</perl>"; return true; }
</php-brief>
Another problem is that we'd often like the ability to use MediaWiki templates even if the content is code, for example when defining LocalSettings articles by transcluding the wiki template and extension templates. So I've also added an extra line of code into the GeSHi extension before it parses the content to achieve this: <php> $source = $GLOBALS["wgParser"]->replaceVariables($source); </php>