User:DrOwl/wikiCode

add a code tag into wiki pages using some regex and the pre tag in a custom Mediawiki extension:

< = &amp;lt;

> = &amp;gt;

[ = &amp;#91;

] = &amp;#92;

its for displaying code and such like below, but with outthe messing about

this is a first untestedversion with justmonkey knolage of how to make it work

example Result

 * '_ ` _ \ / _ \ / _ \
 * | | | | | (_) | (_) |
 * _| |_| |_|\___/ \___/

Source
setHook( "code", "renderCode" ); }
 * 1) extension hook callback function

function renderCode( $input ) { global $wgOutputEncoding; # $input = mysql_escape_string($input); if (!$input) $input = "mu"; #ifno input then mu

$input =~ s/&/&amp;/g; $input =~ s//&gt;/g; $input =~ s/[/&#91;/g; $input =~ s/]/&#92;/g;

$output="  "; $output."$input"; $output.="  ";

return $output;

}

?>