aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 886
1148 credits Members referred : 4
« on: Jun 04, 2007, 07: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, 07: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...)
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 886
1148 credits Members referred : 4
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
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6691
34714 credits Members referred : 374
It's time to use PHP5!
« Reply #6 on: Jun 04, 2007, 09:10:02 pm »
yeah until you upgrade your server to php5
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 886
1148 credits Members referred : 4
« Reply #7 on: Jun 04, 2007, 09: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: 886
1148 credits Members referred : 4
« Reply #9 on: Jun 04, 2007, 10: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
Global Moderator Community Supporter?
Jedai Sword Master
Gender:
Posts: 6691
34714 credits Members referred : 374
It's time to use PHP5!
« Reply #10 on: Jun 04, 2007, 10:18:34 pm »
ok than was my statement not wrong
this function works totally different in php5: highlight_string()
actually in php5 the whole is messed up
the easiest way to handle this code highlighting in php5 is using geshi
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 886
1148 credits Members referred : 4
« Reply #11 on: Jun 04, 2007, 10: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