Esempio n. 1
0
function ExtensionCodeTag()
{
    global $wgParser, $codeTag, $languages, $languagesPath;
    ReadLanguages();
    if ($codeTag["advanced"]["mode"]) {
        $wgParser->setHook('code', 'AdvancedCodeTag');
    }
    if ($codeTag["simple"]) {
        foreach ($languages as $lang) {
            $wgParser->setHook($lang, create_function('$source', '$geshi = new GeSHi($source,\'' . $lang . '\', \'' . $languagesPath . '\');
                                         return $geshi->parse_code();'));
        }
    }
}
Esempio n. 2
0
function ExtensionCodeTag()
{
    global $wgParser, $codeTag, $languages;
    ReadLanguages();
    if ($codeTag["advanced"]["mode"]) {
        $wgParser->setHook('code', 'AdvancedCodeTag');
    }
    if ($codeTag["simple"]) {
        foreach ($languages as $lang) {
            $wgParser->setHook($lang, create_function('$source,$argv,$parser', '
#$source = trim($parser->replaceVariables($source));
                                         $geshi = new GeSHi($source,"' . $lang . '", $GLOBALS["languagesPath"]);
$lang = "' . $lang . '";
if ($lang != "r") {
@$geshi->set_keyword_group_style(1, "font-weight:bold;color:#0022aa;", false);
@$geshi->set_keyword_group_style(2, "color:#3311cc;", false);
@$geshi->set_keyword_group_style(3, "color:#3311cc;", false);
@$geshi->set_url_for_keyword_group(1, "");
@$geshi->set_url_for_keyword_group(2, "");
@$geshi->set_url_for_keyword_group(3, "");
$comment = "font-style:italic;color:#d00000;";
@$geshi->set_comments_style(1,$comment,false);
@$geshi->set_comments_style(2,eregi("^(as|c)$",$lang)?"font-style:italic;color:#ff44aa":$comment,false);
@$geshi->set_comments_style(3,$comment,false);
@$geshi->set_comments_style("MULTI",$comment,false);
@$geshi->set_escape_characters_style("color:#ff0000;",false);
@$geshi->set_brackets_style("font-weight:bold; color:#ff0000;",false);
@$geshi->set_strings_style("color:#0080aa;",false);
@$geshi->set_numbers_style("color:#000000;",false);
@$geshi->set_methods_style("color:#000000;",false);
@$geshi->set_symbols_style("color:#008000;",false);
@$geshi->set_regexps_style("color:#00ffaa;",false);
}
$text = $geshi->parse_code();
$text = preg_replace("/&([lg]t;)/","&$1",$text);
return $text;'));
        }
    }
}