Difference between revisions of "GeSHi"

From Christoph's Personal Wiki
Jump to: navigation, search
(Added "Possible Languages")
("Java" link)
Line 83: Line 83:
 
* ini
 
* ini
 
* inno
 
* inno
* java
+
* [[GeSHi/Java|java]]
 
* javascript
 
* javascript
 
* lisp
 
* lisp

Revision as of 17:33, 17 December 2005

<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"  );
   # Christoph's additions, 17-Dec-2005
   $wgParser->setHook( "css",  "cssHook"  );

}

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' ); }

  1. Christoph's additions, 17-Dec-2005

function cssHook ( $code ) { return formatCode( $code, 'css' ); }

?> </php>

<css> /* --- CSS --- */

div#main { color:#fff; } </css>

Possible Languages

  • actionscript-french
  • actionscript
  • ada
  • apache
  • applescript
  • asm
  • asp
  • bash
  • blitzbasic
  • c
  • c_mac
  • caddcl
  • cadlisp
  • cpp
  • csharp
  • css-gen.cfg
  • css
  • d
  • delphi
  • diff
  • div
  • dos
  • eiffel
  • freebasic
  • gml
  • html4strict
  • ini
  • inno
  • java
  • javascript
  • lisp
  • lua
  • matlab
  • mpasm
  • mysql
  • nsis
  • objc
  • ocaml-brief
  • ocaml
  • oobas
  • oracle8
  • pascal
  • perl
  • php-brief
  • php
  • python
  • qbasic
  • ruby
  • scheme
  • sdlbasic
  • smarty
  • sql
  • vb
  • vbnet
  • vhdl
  • visualfoxpro
  • xml


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!