GeSHi
From Christoph's Personal Wiki
<php> <?php
- vim: ts=8:sw=4:sts=4:et
- MediaWiki GeSHiColor version 0.0
- Copyright (c) 2005 Aran Clary Deltac
- http://arandeltac.com/MediaWiki_GeSHiColor
- Distributed under that same terms as MediaWiki itself.
include_once('geshi/geshi.php');
$wgExtensionFunctions[] = "wfGeSHiColorExtension";
function wfGeSHiColorExtension() {
global $wgParser; $wgParser->setHook( "code", "codeHook" ); $wgParser->setHook( "php", "phpHook" ); $wgParser->setHook( "perl", "perlHook" ); $wgParser->setHook( "bash", "bashHook" ); $wgParser->setHook( "mysql", "mysqlHook" ); $wgParser->setHook( "html", "htmlHook" );
}
function hookCode( $code, $args ) {
$type = ; if ($args['type']) { $type=$args['type']; } return formatCode( $code, $type );
}
function formatCode( $code, $type ) {
if (!$type) { die('No language type defined for code block.'); } $geshi =& new GeSHi( trim($code), $type ); return $geshi->parse_code();
}
function phpHook ( $code ) { return formatCode( $code, 'php' ); } function perlHook ( $code ) { return formatCode( $code, 'perl' ); } function bashHook ( $code ) { return formatCode( $code, 'bash' ); } function mysqlHook ( $code ) { return formatCode( $code, 'mysql' ); } function htmlHook ( $code ) { return formatCode( $code, 'html' ); }
?> </php>