addAction('post_content', 'source_code_beautifier'); } function source_code_beautifier() { global $rows; $text = $rows[0]['Body']; $result = preg_replace_callback("/(.*)<\/code>/siU", array('kodrs', 'replace_with_geshi'), $text); $rows[0]['Body'] = $result; } static function replace_with_geshi($matches) { $lang = strtolower($matches[1]) ; $code = trim($matches[2]); $geshi = new geshi($code, (isset($lang)) ? $lang : ""); $geshi->enable_classes(false); $geshi->set_overall_id('geshi_code'); return @$geshi->parse_code(); } } ?>