GeSHi

From Christoph's Personal Wiki
Revision as of 16:22, 17 December 2005 by Christoph (Talk | contribs) (+stub)

Jump to: navigation, search

<php> <?php

  1. vim: ts=8:sw=4:sts=4:et
  1. MediaWiki GeSHiColor version 0.0
  2. Copyright (c) 2005 Aran Clary Deltac
  3. http://arandeltac.com/MediaWiki_GeSHiColor
  4. 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>

This article is curently a "stub". This means it is an incomplete article needing further elaboration.

I always welcome suggestions, comments, and criticism. If you have something to contribute to this site, please follow this link: Contributing Information. Thank you!