Content added Content deleted
imported>DrOwl (a test for a code tag =)) |
imported>DrOwl mNo edit summary |
||
Line 17: | Line 17: | ||
==== Example ==== |
==== Example ==== |
||
<nowiki><code> |
<nowiki><code>some code including html tags and such things... </code></nowiki> |
||
=== example Result === |
=== example Result === |
||
<pre> |
<pre> |
||
just the code form above displayed instead of "run" =) |
|||
| '_ ` _ \ / _ \ / _ \ |
|||
| | | | | | (_) | (_) | |
|||
|_| |_| |_|\___/ \___/ |
|||
</pre> |
</pre> |
||
Revision as of 23:59, 20 June 2005
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; $output="<pre>"; $output."$input"; $output.="<nowiki>
</nowiki>";
return $output;
}
?>