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.