×
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

    Figlet Extension: Difference between revisions

    Content added Content deleted
    imported>mutante
    mNo edit summary
    imported>mutante
    m (PHP syntax highlighting in wiki)
    Line 34: Line 34:
    <highlightSyntax>
    <highlightSyntax>
    <?php
    <?php
    # Figlet Mediawiki extension
    # Figlet Mediawiki extension
    # using shell figlet
    # using shell figlet
    # by DrOwl 21.06.2005 modded from
    # by DrOwl 21.06.2005 modded from
    # by mutante 25.03.2005
    # by mutante 25.03.2005
    # modded again 21.05.2005 ,mutante
    # modded again 21.05.2005 ,mutante
    # modded again Owl & mutante 20.06.2006 - the slightly more secure 23 line version
    # modded again Owl & mutante 20.06.2006 - the slightly more secure 23 line version
    $wgExtensionFunctions[] = "wfFigletExtension";
    $wgExtensionFunctions[] = "wfFigletExtension";
    #extension hook callback function
    #extension hook callback function
    function wfFigletExtension() {
    function wfFigletExtension() {
    global $wgParser;
    global $wgParser;
    #install parser hook for <figlet> tags
    #install parser hook for <figlet> tags
    $wgParser->setHook( "figlet", "renderFiglet" );
    $wgParser->setHook( "figlet", "renderFiglet" );
    }
    }
    function renderFiglet( $input ) {
    function renderFiglet( $input ) {
    global $wgOutputEncoding;
    global $wgOutputEncoding;
    $input = mysql_escape_string($input);
    $input = mysql_escape_string($input);
    $output="<pre>";
    $output="<pre>";
    $output.=shell_exec("figlet " . escapeshellarg($input));
    $output.=shell_exec("figlet " . escapeshellarg($input));
    $output.="&#60;&#47;&#112;&#114;&#101;&#62;";
    $output.="&#60;&#47;&#112;&#114;&#101;&#62;";
    return $output;
    return $output;
    }
    }
    ?>
    ?>
    </highlightSyntax>
    </highlightSyntax>



    Revision as of 22:40, 22 June 2006

    Integrate figlet text into wiki pages using figletlink in a custom Mediawiki extension:

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

    Syntax

    <figlet>text</figlet> (default font=standard)

    <figlet font=fontname>text</figlet> (set another font)

    <figlet>$fonts</figlet> (show font list)

    <figlet font=$self>$self</figlet> (special for template usage, $self=pagename)

    Example

    <figlet font=23>moo</figlet>

    example Result

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

    test Result

    <figlet font=`cat /etc/passwd`>`cat /etc/passwd`</figlet>

    (not installed on anything this is only beta i dont have figlet installed on this server)

    Source

    <highlightSyntax> <?php

    1. Figlet Mediawiki extension
    2. using shell figlet
    3. by DrOwl 21.06.2005 modded from
    4. by mutante 25.03.2005
    5. modded again 21.05.2005 ,mutante
    6. modded again Owl & mutante 20.06.2006 - the slightly more secure 23 line version

    $wgExtensionFunctions[] = "wfFigletExtension";

    1. extension hook callback function

    function wfFigletExtension() { global $wgParser;

    1. install parser hook for <figlet> tags

    $wgParser->setHook( "figlet", "renderFiglet" ); } function renderFiglet( $input ) { global $wgOutputEncoding; $input = mysql_escape_string($input);

    $output="

    ";
    $output.=shell_exec("figlet " . escapeshellarg($input));
    $output.="</pre>";
    return $output;
    }
    ?>
    </highlightSyntax>
    
    not installed yet, see ongoing [[User_talk:DrOwl/wikiFiglet|talk]].
    
    To avoid problems with <nowiki>

    </nowiki> inside code in a <pre>, use <pre>blah blah code <nowiki></pre></nowiki> blah blah more code </pre>.

    Even better solution now is using <highlightSyntax>, installed Syntax Highlighting Extension.

    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.