Brandon Jaeger Posted April 30, 2006 Share Posted April 30, 2006 How would I highlight a string of C++ code including syntax highlighting?Edit: Ok, so I've found GESHI now I need some help.How would I highlight what's between the [pawn][/pawn] tags with this?[code]geshi_highlight($string , "cpp" , "" , false);[/code]Edit #2: I sort of got it but the backslashes still appear. Here's my code: [code] function pawn_highlight($string) { $string = str_replace("]\n", "]", $string); $match = array('#\[pawn\](.*?)\[\/pawn\]#se'); $replace = array("'<div>'.geshi_highlight('$1' , 'cpp' , '' , false).'</div>'"); $string = stripslashes($string); return preg_replace($match, $replace, $string); }[/code]Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/8745-solved-c-highlighting/ Share on other sites More sharing options...
Brandon Jaeger Posted April 30, 2006 Author Share Posted April 30, 2006 Nevermind, I believe I've solved it myself:[code] function pawn_highlight($string) { $string = str_replace("]\n", "]", $string); $match = array('#\[pawn\](.*?)\[\/pawn\]#se'); $replace = array("'<div>'.geshi_highlight(stripslashes('$1') , 'cpp' , '' , true).'</div>'"); return preg_replace($match, $replace, stripslashes(stripslashes($string))); // I used stripslashes twice }[/code]Edit: If anyone wants to see a live example of it, go here: [a href=\"http://ghw-amxx.com/pawn_hl.php\" target=\"_blank\"]http://ghw-amxx.com/pawn_hl.php[/a] Quote Link to comment https://forums.phpfreaks.com/topic/8745-solved-c-highlighting/#findComment-32120 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.