Extension talk:SyntaxHighlight GeSHi/Archive 2009

Fatal Error?

After I installed it, I tried <syntaxhighlight lang="c"> </syntaxhighlight>

Then the browser turned into a white background with words like that."

Fatal error: Call to undefined function wfLoadExtensionMessages() in D:\wamp\www\mediawiki-1.9.3\extensions\SyntaxHighlight_GeSHi\SyntaxHighlight_GeSHi.class.php on line 288 "

the line 288 of SyntaxHighlight_GeSHi.class.php is this:

wfLoadExtensionMessages( 'SyntaxHighlight_GeSHi' );

I think I must miss something important when I installed this extension. Any one can help?

Not using external stylesheet

The documentation for GeSHi states:

in particular, if you’re making a plugin for a forum/wiki/other system, using an external stylesheet is a good idea!

Still, this extension outputs the CSS for used classes inline, in the buildHeadItem function. This is inelegant (includes presentation information in HTML code), wasteful (a block of CSS for every page request) and redundant (in case an installation also uses the MediaWiki:Geshi.css page). --IP 4 January 2009

SQL

hi, i get the following error message after installing it:

GeSHi Error: GeSHi could not find the language php (using path D:\www\www1145\Techie\extensions\SyntaxHighlight_GeSHi\geshi\geshi\) (code 2)

You need to specify a language like this: < source lang="html4strict" >...</ source >"

Supported languages for syntax highlighting:

abap, actionscript, actionscript3, ada, apache, applescript, apt_sources, asm, asp, autoit, avisynth, bash, basic4gl, bf, blitzbasic, bnf, boo, c, c_mac, caddcl, cadlisp, cfdg, cfm, cil, cobol, cpp, cpp-qt, csharp, css, d, delphi, diff, div, dos, dot, eiffel, email, fortran, freebasic, genero, gettext, glsl, gml, gnuplot, groovy, haskell, hq9plus, html4strict, idl, ini, inno, intercal, io, java, java5


and i was wondering aswell if i can use the language sql or do i need another extension for this?

because i made my own wiki site and i wanted to copy a link from the original wikipedia site but it wont display it correctly, it keeps saying


< source lang="sql">blablabla< /source>

and i want to get rid of that source language tag and let it be displayed correctly, do i need another extension for that??

thanks

PHP: Call_user_func_array() error

Have just installed the extension for the customer - verified permissions and installation several times, and have checked out latest code from SVN, but am getting the following error message:

Warning: call_user_func_array(): First argumented is expected to be a valid callback, 'SyntaxHighlight_GeSHi::parserHook' was given in /home/username/public_html/includes/Parser.php on line 468

Are there any issues with particular versions of MediaWiki?

I get a similar error on Mediawiki 1.5.8 Warning: call_user_func_array() [<a href='function.call-user-func-array'>function.call-user-func-array</a>]: First argument is expected to be a valid callback, 'SyntaxHighlight_GeSHi::parserHook' was given in C:\wamp\www\wiki\includes\Parser.php on line 436
--202.12.233.21 01:10, 3 February 2009 (UTC)Reply

I get the same thing running MediaWiki on a Windows server. Tried everything. Given up.

That sounds like the kind of error you'd get running a new extension on an outdateved version of mediawiki. According to the descriptions, it should work on Mediawiki versions 1.10+. -Steve Sanbeg 00:39, 26 February 2009 (UTC)Reply

I had the same problem. I used this extension: [[1]] with PHP4 and MW 1.6 and it works with GeSHi 1.0.7

Found bugs with Powershell language

Found bugs with Powershell language- is there somewhere I can share the fix? If anyone is interested.

Problems and bugs with language files should be reported upstream to BenBE@geshi.org. This also includes bugs when the highlighted version visually includes additional characters that didn't appear in your source --BenBE 13:02, 24 April 2009 (UTC)Reply

Add character at the beginning of each line

I want to use this extension to add a special character at the beginning of each line like "#" for root shell or "$" for user shell. Is it possible ? Do you have any idea how I can do that ?

You can use the CSS :after pseudo-class to add additional content. --BenBE 13:04, 24 April 2009 (UTC)Reply

Unclear Installation and Pre-Requisite Instructions

Do I need to install Geshi into my PHP directory before I install the Geshi MediaWiki Extension? Also are there any prerequisites for this extension? Like the Geshi extension or the stub manager please? Thanks!

Also: step 2 of "installation" instructions is confusing for me, being somewhat new to both mediawiki and unix environment. I do NOT have shell access to my account, and though step 1 leads me to believe I don't need shell access, step 2 is explained as if I do have it. Can this be clarified?

Casing problem with T-SQL

Many of the keywords (System Stored Procedures) are in lower case. Using GESHI causes things like sp_executesql to be rendered as SP_EXECUTESQL, which is not a valid procedure. Very easy fix, I know (just change the file ...SyntaxHighlight_GeSHi/geshi/geshi/tsql.php to use "GESHI_CAPS_NO_CHANGE" instead of "GESHI_CAPS_UPPER") but should be set that way be default.

Error if i have <Source> inside the box....

 <syntaxhighlight lang=xml>
 <?xml version="1.0"?>
 <Object>
 	<Control>
 	    <Source>  // This is the original source from my XML file
 	    	......
 	    </Source> // This is the original source from my XML file
 	</Control>
 </Object>
 </syntaxhighlight>
 

How can i fix that? Please help! Thanks in advance! -- Frankz (talk) 14:12 April 17, 2009 (EST)

Now I hacked into SyntaxHighlight_GeSHi.php added 's' to the end of 'source' and replaced <syntaxhighlights lang=xml></sources> on the above and it works! -- Frankz (talk) 16:26 April 17, 2009 (EST)

Here is solution: go to

/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php

find

$wgParser->setHook( 'source', array( 'SyntaxHighlight_GeSHi', 'parserHook' ) ); 

replaced with

$wgParser->setHook( 'sources', array( 'SyntaxHighlight_GeSHi', 'parserHook' ) );

Defaul Language?

Hi.

In a wiki I maintain, we're using the SyntaxHighlight_GeSHi extension. Since the main need is "C" code, I found it useful to have a default language.

I added a new variable to LocalSettings.php, just before the require_once line:

$wgSyntaxHighlightDefaultLang = "c";
require_once("extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php");

In SyntaxHighlight_GeSHi.class.php, I changed the parserHook function.

The original code:

    public static function parserHook( $text, $args = array(), $parser ) {
        self::initialise();
        $text = rtrim( $text );
        // Don't trim leading spaces away, just the linefeeds
        $text = preg_replace( '/^\n+/', '', $text );
        // Validate language
        if( isset( $args['lang'] ) ) {
            $lang = strtolower( $args['lang'] );
        } else {
            return self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) );
        }

Modified code:

    public static function parserHook( $text, $args = array(), $parser ) {
       global $wgSyntaxHighlightDefaultLang;
        self::initialise();
        $text = rtrim( $text );
        // Don't trim leading spaces away, just the linefeeds
        $text = preg_replace( '/^\n+/', '', $text );
        // Validate language
        if( isset( $args['lang'] ) ) {
            $lang = strtolower( $args['lang'] );
        } else {
            // language is not specified. Check if default exists, if yes, use it.
            if ( isset($wgSyntaxHighlightDefaultLang) ) {
                $lang = strtolower($wgSyntaxHighlightDefaultLang);
            } else {
                return self::formatError( htmlspecialchars( wfMsgForContent( 'syntaxhighlight-err-language' ) ) );
            }
        }

I hope someone will find it useful.

Template Expansion

Apologies ahead of time if it's bad etiquette to post here. I've been at this all day and am pretty frustrated. Desperate.

I want to create code templates where I have something like Template:MyTemplate

#Grab the file
wget {{{FileUrl}}}

#Unpack it
tar -zxvf {{{Filename}}}

Turns out that the template variables don't get expanded, and my life is very unhappy.

Is it possible to make this work?

I have been doing some research and this might legitimately be a limitation of mediawiki bugzilla:2257. I'm too new to understand whether this is exactly the problem, and whether any of the suggested workarounds can help me. Thanks in advance if anyone can throw me a bone.

I followed your bug link above and it seems as if it's been fixed. I just ran into the same issue where I'd like to pass code into a template that has a parameter inside of my code tags. Does anyone know how to do this? --Gkullberg 19:26, 12 November 2009 (UTC)Reply


How about me? I have a similar problem. I'd like to create a template called "source code" as follows:
{{source code|lang|code or program}}

I tried making this sample in my template but seemed not working as expected: {{#switch: {{{1}}} | html4strict <syntaxhighlight lang="html4strict">{{{2}}}</syntaxhighlight> | basic | qbasic=<syntaxhighlight lang="qbasic">{{{2}}}</syntaxhighlight> | c=<syntaxhighlight lang="c">{{{2}}}</syntaxhighlight> | #default <syntaxhighlight lang="html4strict">{{{2}}}</syntaxhighlight> }}

The problem is that the second argument, {{{2}}} remains as if it is a string "{{{2}}}" not a variable. Can any one correct this for me?--Email4mobile 00:31, 28 January 2010 (UTC)Reply

Is Vimscript supported or not?

The error I get when doing <syntaxhighlight lang="vim">:

GeSHi Error: GeSHi could not find the language vim (using path /usr/local/apache/common-local/php-1.5/lib/GeSHi-1.0.7.19-wm1/geshi/) (code 2)

Kazkaskazkasako 15:32, 18 June 2009 (UTC)Reply

You need a more recent version of GeSHi. This extension installs revision 1402. You need revision 1933+. -- 99.185.243.218 01:52, 19 June 2009 (UTC)Reply

Fatal Error when installed with v1.14

I just installed this extension on my site and got a fatal error. Has anyone had any problem using this with v1.14? or am I just missing something in the install? --Jake4d 19:11, 20 June 2009 (UTC)Reply

I started over, and realized I missed the part about having to install GeSHi separately. This done, it is working great. Thanks for this nice extension User:jake4d

No CSS Classname compatibility with geshi/contrib/cssgen.php

In the Geshi Highlighter package, the /geshi/contrib has a script called cssgen.php that creates css class styles, but the SyntaxHighlight extension creates its own class names. I think this extension should use the same class names as the original Geshi, not ones just made up.

comparison css class names
geshi cssgen SyntaxHighlight extension
.php .kw1 .php.source-php .kw1

The problem is that the extension builds its css class names with greater specificity, so that ".php .kw1" gets out specified against ".php .source-php .kw1". If the SyntaxHighlight extension didn't have the .source-(Language) class specifier, then it would work well with the Geshi distribution/contrib.

My solution was to comment out line 204 in SyntaxHighlight_GeSHi.class.php

$geshi->set_overall_class( "source-$lang" ); // comment out this line

Where is the geshi.php file?

--almaghi 22:17, 29 June 2009 (UTC)Reply

It should be in a subdirectory of your extension called 'geshi'. (ie: MW_ROOT/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php). Note that this is automatically checked out in SVN, it's set as an external and grabs directly from the GeSHi project. ^demon 20:03, 30 June 2009 (UTC)Reply

Request for vCard and iCalendar language support

It would be great if vCard (RFC 2426) and iCalendar (RFC 2445) language support could be added to the extension.

Here are examples of two of several wiki pages that would make use of this feature:

Thanks for your consideration. Tantek 23:29, 6 July 2009 (UTC)Reply

Compile some language file for those two formats and forward the final language files to me (when they pass the langcheck script). --BenBE 12:43, 2 May 2010 (UTC)Reply

PHP Warnings

MediaWiki 1.15.1

GeSHi 1.0.8.4

PHP Warning:  preg_match(): Compilation failed: unrecognized character after (?< at offset 3 in /www/mediawiki/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 2132

To fix this replace following lines in extensions\SyntaxHighlight_GeSHi\geshi\geshi\php.php:

       4 => "/(?<start><\\?(?>php\b)?)(?:".
            "(?>[^\"'?\\/<]+)|".
            "\\?(?!>)|".
            "(?>'(?>[^'\\\\]|\\\\'|\\\\\\\|\\\\)*')|".
            "(?>\"(?>[^\"\\\\]|\\\\\"|\\\\\\\\|\\\\)*\")|".
            "(?>\\/\\*(?>[^\\*]|(?!\\*\\/)\\*)*\\*\\/)|".
            "\\/\\/(?>.*?$)|".
            "\\/(?=[^*\\/])|".
            "<(?!<<)|".
            "<<<(?<phpdoc>\w+)\s.*?\s\k<phpdoc>".
            ")*(?<end>\\?>|\Z)/sm",
       5 => "/(?<start><%)(?:".
            "(?>[^\"'%\\/<]+)|".
            "%(?!>)|".
            "(?>'(?>[^'\\\\]|\\\\'|\\\\\\\|\\\\)*')|".
            "(?>\"(?>[^\\\"\\\\]|\\\\\"|\\\\\\\\|\\\\)*\")|".
            "(?>\\/\\*(?>[^\\*]|(?!\\*\\/)\\*)*\\*\\/)|".
            "\\/\\/(?>.*?$)|".
            "\\/(?=[^*\\/])|".
            "<(?!<<)|".
            "<<<(?<phpdoc>\w+)\s.*?\s\k<phpdoc>".
            ")*(?<end>%>)/sm",


With these:

        4 => "/(<\?(?:php)?)(?:'(?:[^'\\\\]|\\\\.)*?'|\"(?:[^\"\\\\]|\\\\.)*?\"|\/\*(?!\*\/).*?\*\/|.)*?(\?>|\Z)/sm",
        5 => "/(<%)(?:'(?:[^'\\\\]|\\\\.)*?'|\"(?:[^\"\\\\]|\\\\.)*?\"|\/\*(?!\*\/).*?\*\/|.)*?(%>|\Z)/sm",

Getting another language supported

How do I get another language supported by the Geshi support in Wikibooks? The Geshi syntax file is already written ([2]), but presumably needs to be added or installed at some location? Newlisp 07:17, 27 September 2009 (UTC)Reply

It's in current releases, thus the guys of the MW extension need to pull an updated GeSHi release and install it here. IDK when they will do. At least: 1.0.8.8 is coming soon. --BenBE 12:41, 2 May 2010 (UTC)Reply

Problem with z80 code

When using the keyword ret in z80 assembler, it becomes after adding <syntaxhighlight> tags: 1/>ret --81.205.98.108 16:59, 7 October 2009 (UTC)Reply

Has already been fixed in current releases. --BenBE 12:39, 2 May 2010 (UTC)Reply

Description of setting default language

The page says to set the default you can"add a new variable to LocalSettings.php, just before the require_once line. We set C programming language as an example:" It gives the example code

require_once("extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php");
$wgSyntaxHighlightDefaultLang = "c";

It seems to me that in this example, the variable is set after the require_once line, not before, but I don't know enough about this module to want to change it.--Nigelpackham 17:46, 14 October 2009 (UTC)Reply

This is correct, setting the variable before the require will cause it to be overridden with the default value. Mr.Z-man 17:51, 14 October 2009 (UTC)Reply

Warnings with lang=""

Try this:

<syntaxhighlight lang="">
foo
</syntaxhighlight>

and you get this:

Notice:  Undefined index:  KEYWORDS in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 1925
Warning:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 1925
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 1925
Notice:  Undefined index:  ESCAPE_CHAR in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 2270
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 2290
Warning:  implode() [<a href='function.implode'>function.implode</a>]: Argument to implode must be an array. in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 3242
Notice:  Undefined index:  KEYWORDS in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 3265
Warning:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 3265
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 3265
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 3306
Notice:  Undefined index:  KEYWORDS in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 3357
Warning:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 3357
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 3357
Notice:  Undefined index:  OOLANG in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 3388
Warning:  array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 3502
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 3502
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 4338
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 4345
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 4354
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 4363
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 4368
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 4373
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 4382
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 4387
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 4393
Warning:  Invalid argument supplied for foreach() in /var/www/html/w/extensions/SyntaxHighlight_GeSHi/geshi/geshi.php on line 4398

This seems like an easy case to catch and display a more friendly message.... Maiden taiwan 19:41, 19 November 2009 (UTC)Reply

Easy fix in SyntaxHighlight_GeSHi.class.php function parserHook: Change this:
if( isset( $args['lang'] ) ) {
to this:
if( isset( $args['lang'] ) && $args['lang'] ) {
The warnings are gone. Maiden taiwan 19:48, 19 November 2009 (UTC)Reply
Thanks, committed in r59269. Max Semenik 20:38, 19 November 2009 (UTC)Reply

Can't download for 1.15.x via Extension Distributor

When I try and download via the ExtensionDistributor, I choose my wiki version (1.15.x) and then get this error:

  Invalid response from remote subversion client.
Must be an intermittent glitch, it worked for me. Use this direct link. Max Semenik 17:39, 24 November 2009 (UTC)Reply
Return to "SyntaxHighlight GeSHi/Archive 2009" page.