×
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
    Revision as of 23:07, 22 May 2005 by imported>DrOwl (a test for a code tag =))
    (diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

    < = &lt;

    > = &gt;

    [ = &#91;

    ] = &#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

    Syntax

    <code>text</code>

    Example

    <code>moo</code>

    example Result

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


    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;

    }

    ?>

    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.