×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    User:DrOwl/wikiCode: Difference between revisions

    Content added Content deleted
    imported>DrOwl
    (# added in a few more regEx's and renamed to code2)
    imported>DrOwl
    mNo edit summary
    Line 1: Line 1:
    ===Discription===

    add a code2 tag into wiki pages using some regex and the pre tag in a custom [[Mediawiki]] extension:
    add a code2 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 out the messing about
    &;lt; = <
    we need to replace out any code that wiki might process...


    ==symbols wiki uses and there excape codes==
    &;gt; = >

    < = <

    > = >


    # = #
    # = #


    &;#91; = [
    [ = [


    &;#92; = \
    \ = \


    { = {
    { = {
    Line 18: Line 25:


    ~ = ~
    ~ = ~

    its for displaying code and such like below, but with out the messing about
    we need to replace out any code that wiki might process...


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

    === Syntax ===
    === Syntax ===
    <nowiki><code2>text</code2></nowiki>
    <nowiki><code2>text</code2></nowiki>

    Revision as of 11:57, 23 June 2006

    Discription

    add a code2 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 out the messing about we need to replace out any code that wiki might process...

    symbols wiki uses and there excape codes

    < = &lt;

    > = &gt;

    # = &#35;

    [ = &#91;

    \ = &#92;

    { = &#123;

    | = &#124;

    } = &#125;

    ~ = &#126;

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

    Syntax

    <code2>text</code2>

    Example

    <code2>some code including &;lt;b&;gt; html&;lt;/b&;gt; tags and such things... </code2>

    example Result

    just the code form above displayed instead of "run" ie the &;lt;b&;gt; bit isnt in bold  =)
    


    Source

    <?php
    # code Mediawiki extension
    # using regex
    # by DrOwl 21.06.2005  <- a Date in the Future ,ehe ;)
    # upDated 23.06.2006 
    # added in a few more regEx's and renamed to code2 
    
    #install extension hook
    $wgExtensionFunctions[] = "wfCodeExtension";
    
    
    #extension hook callback function
    function wfCodeExtension() { 
      global $wgParser;
     
      #install parser hook for <code2> tags
      $wgParser->setHook( "code2", "renderCode" );
    }
    
    function renderCode( $input ) {
    global $wgOutputEncoding;
        
    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;
    $input =~ s/{/{/g;
    $input =~ s/|/|/g;
    $input =~ s/}/}/g;
    $input =~ s/~/~/g;
    
    $output="<pre>";
    $output."$input";
    $output.="<nowiki>

    </nowiki>";

    return $output;

    }

    ?>

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.