aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« on: Jun 04, 2007, 08:11:22 PM »
I have spent a good hour or so trying to incorporate Geshi syntax coloring into the [ code ] bbCode element for phpHaze.. but im running into some wierd problems, i tested geshi first outside of the bbCode in a separate file and it worked great, so i know its not Geshi, its of course me
after adding it to the bbCode a few different ways, i could never get it to work.. so i stored the geshi caller in a function that could be easily called upon within the bbCode function.. and this is what i have:
include INCLUDES."geshi/geshi.php"; function geshiTxt($text, $lang="php"){ $geshi =& new GeSHi($text, $lang); return $geshi->parse_code(); }
and here is where inside the bbCode function, it searches for [ code ] and performs the geshi function to colorize the code in side the tags appropriately
Code:
<?php function bbCode($text){ //...more things are here, but are irrelevant $ccount = substr_count($text, "[ code ]");//note the extra spacing added to prevent WebDigity from parsing that tag for ($i=0;$i < $ccount;$i++) $text = preg_replace('#\[code\](.*?)\[/code\]#si', '<div class=\'quote\' style=\'width:400px;white-space:nowrap;overflow:auto\'><code style=\'white-space:nowrap\'>'.geshiTxt('\1').'<br /><br /><br /></code></div>', $text); return $text; } ?>
when used, this is the output:
Quote
\1
except that the 1 is pink, so i know that the geshiTxt function is operating correctly.. just cant figure out how to force geshiTxt into that preg_replace function.. any ideas?
« Last Edit: Jun 04, 2007, 08:13:58 PM by Meth0d »
or your parse the bbcode back and parse the result with geshi
so, what if i take the [ code] part of function.bbCode out, and parse the other bbCode first.. next parse what is left with geshiTxt instead of using geshiTxt inside of bbCode? still though.. doing this is almost the same yes? but i need to split the [ code] parser so that geshiTxt doesnt mess with that? ive tried a numerous amount of ways and geshi attempts to pase [ code], then colorize it, breaking the code so the code box never appears
so, what if i take the [ code] part of function.bbCode out, and parse the other bbCode first.. next parse what is left with geshiTxt instead of using geshiTxt inside of bbCode? still though.. doing this is almost the same yes? but i need to split the [ code] parser so that geshiTxt doesnt mess with that? ive tried a numerous amount of ways and geshi attempts to pase [ code], then colorize it, breaking the code so the code box never appears
you need to parse something that geshi can understand (html, php, css...)
so, what if i take the [ code] part of function.bbCode out, and parse the other bbCode first.. next parse what is left with geshiTxt instead of using geshiTxt inside of bbCode? still though.. doing this is almost the same yes? but i need to split the [ code] parser so that geshiTxt doesnt mess with that? ive tried a numerous amount of ways and geshi attempts to pase [ code], then colorize it, breaking the code so the code box never appears
you need to parse something that geshi can understand (html, php, css...)
thanks for the help guys, i found it easier to just write my own Geshi function ... and it works great
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« Reply #7 on: Jun 04, 2007, 10:51:03 PM »
nah Olaf, i do not think there will be any problems. i am not using geshiTxt inside of that preg_replace function anymore, made an entire new bbCode function separately for [ php ] .. wont affect a php upgrade
nah Olaf, i do not think there will be any problems. i am not using geshiTxt inside of that preg_replace function anymore, made an entire new bbCode function separately for [ php ] .. wont affect a php upgrade
your post before sound like you're not using geshi anymore right?
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« Reply #9 on: Jun 04, 2007, 11:01:35 PM »
ya, im not using Geshi anymore.. i will probably use it for phpHaze or something, because what i am doing here is for another site.. and Geshi just wasnt working for it
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« Reply #11 on: Jun 04, 2007, 11:27:16 PM »
ah ok I see what you are saying; you are right then as this uses highlight_string.. but as i said before Geshi just will not work out of the box, will require some modifications of the source to integrate into what im trying to do
i guess what I am doing now, will work fine until php5 replaces our current version.. when that time comes... Olaf, you may hear my questions again hehehe