Content added Content deleted
imported>DrOwl No edit summary |
imported>DrOwl m (→Source) |
||
Line 59: | Line 59: | ||
$input =~ s/>/>/g; |
$input =~ s/>/>/g; |
||
$input =~ s/[/[/g; |
$input =~ s/[/[/g; |
||
$input =~ s/]/&# |
$input =~ s/]/]/g; |
||
$input =~ s/|/|/g; |
$input =~ s/|/|/g; |
||
Revision as of 20:17, 20 June 2006
add a code tag into wiki pages using some regex and the pre tag in a custom Mediawiki extension:
< = <
> = >
[ = [
] = \
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
Syntax
<code>text</code>
Example
<code>some code including html tags and such things... </code>
example Result
just the code form above displayed instead of "run" =)
Source
<?php
# code Mediawiki extension
# using regex
# by DrOwl 21.06.2005 <- a Date in the Future ,ehe ;)
#modded from
# by mutante 25.03.2005
#install extension hook
$wgExtensionFunctions[] = "wfCodeExtension";
#extension hook callback function
function wfCodeExtension() {
global $wgParser;
#install parser hook for <code> tags
$wgParser->setHook( "code", "renderCode" );
}
function renderCode( $input ) {
global $wgOutputEncoding;
# $input = mysql_escape_string($input);
if (!$input) $input = "mu"; #ifno input then mu
$input =~ s/&/&/g;
$input =~ s/</</g;
$input =~ s/>/>/g;
$input =~ s/[/[/g;
$input =~ s/]/]/g;
$input =~ s/|/|/g;
$output="<pre>";
$output."$input";
$output.="<nowiki>
</nowiki>";
return $output;
}
?>