Topic: Add GeSHi in the parser

Hello

I had try to add GeSHi (Generic Syntax Highlighter) in the parser to do color code. 
To do that, I had create a function:

function coloration($matches){
 if ($matches[1] == "html"){
 $matches[1] == "html4strict";
 }
 $geshi = new GeSHi($matches[2], $matches[1]);
 if ($matches[1] == "html4strict"){
  return $geshi->parse_code();
 }
 else {
 return '<div id="geshi"><strong>Code '.strtoupper($matches[1]).':</strong><div class="code">'.$geshi->parse_code().'</div></div>';
 }
}

and I've put it in "parser.php", before the function "do_bbcode($text);.
At the end of this function, I've add these lines (before return($text);):

include_once('../geshi/geshi.php');
$text = preg_replace_callback('#\[code=(.+)\](.+)\[/code_color\]#i', 'coloration', $text);

But when I tape this code:

[code=php]$variable = "ma variable";[/code_color]

In the forum, I view it:

Code PHP:
$variable = "ma variable";

The code is with no colours. 

How can I regulate this problem???
Thanks.

Re: Add GeSHi in the parser

Doesn't GeSHi require you to start highlighted code with their opening tags (if applicable)? So you'd do

<?php $var = "my var"; ?>

Re: Add GeSHi in the parser

Moved to Modifications

Re: Add GeSHi in the parser

Nothing change.  When I tape this:

[code=php]<? $variable = "ma variable"; ?>[/code_color]

I view it:

Code PHP:
<? $variable = "ma variable"; ?>

Re: Add GeSHi in the parser

Could you paste your copy of parser.php?

Re: Add GeSHi in the parser

For the file "parser.php",click here

7

Re: Add GeSHi in the parser

Check this mod
http://www.punres.org/viewtopic.php?id=188

If your people come crazy, you will not need to your mind any more.