5, September 2008

adding geshi to bbCode - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: adding geshi to bbCode
« previous next »
Pages: [1] Print

Author Topic: adding geshi to bbCode  (Read 982 times)
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
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  Tongue

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 »

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8037
41179 credits
Members referred : 3



« Reply #1 on: Jun 04, 2007, 08:38:34 PM »

You can't do this.

First you need to get what is inside the
Code:
bbcode and then replace it

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6309
38674 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Jun 04, 2007, 08:49:32 PM »

or your parse the bbcode back and parse the result with geshi


Last blog : Is your website is down? Know before your visitors do!
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #3 on: Jun 04, 2007, 09:18:17 PM »

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

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6309
38674 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Jun 04, 2007, 09:48:13 PM »



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...)


Last blog : Is your website is down? Know before your visitors do!
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #5 on: Jun 04, 2007, 10:08:36 PM »



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 Smiley

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6309
38674 credits
Members referred : 374


It's time to use PHP5!


« Reply #6 on: Jun 04, 2007, 10:10:02 PM »

yeah until you upgrade your server to php5 Wink


Last blog : Is your website is down? Know before your visitors do!
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
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 Wink

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6309
38674 credits
Members referred : 374


It's time to use PHP5!


« Reply #8 on: Jun 04, 2007, 10:57:31 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 Wink

your post before sound like you're not using geshi anymore right?


Last blog : Is your website is down? Know before your visitors do!
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
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 Tongue

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6309
38674 credits
Members referred : 374


It's time to use PHP5!


« Reply #10 on: Jun 04, 2007, 11:18:34 PM »

ok than was my statement not wrong Smiley

this function works totally different in php5:
highlight_string()

actually in php5 the whole is messed up Sad

the easiest way to handle this code highlighting in php5 is using geshi Smiley


Last blog : Is your website is down? Know before your visitors do!
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
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 Tongue

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

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6749
Tags : geshi bbcode php Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: adding geshi to bbCode
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Sep 05, 2008, 06:46:33 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 36.294
Total Topics: 7.477
Total Members: 3.899
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: speedy5044

30 Guests, 5 Users online :

13 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.