Is there a tutorial one how to color the fonts?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Erfangc
Forum Newbie
Posts: 11
Joined: Sat Jul 29, 2006 2:21 pm

Is there a tutorial one how to color the fonts?

Post by Erfangc »

Is there any kind of online tutorial (I googled it with no luck) that will teach me how to create something similar to the effect of the [code ) tag?
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post by jamiel »

I'd assume it's just regular expressions.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The

Code: Select all

tags only do one color: green. Maybe you're more referring to the

Code: Select all

or [syntax] tags? They are powered by [url=http://qbnz.com/highlighter/]Geshi[/url].

the

Code: Select all

tags are basically a glorified <pre> tag with some style settings on the font's color via CSS.
Erfangc
Forum Newbie
Posts: 11
Joined: Sat Jul 29, 2006 2:21 pm

Post by Erfangc »

besides the default documentation. Is there a comprehensive tutorial on GeShi?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If you're looking to color php code only, you could use php's internal coloring controls: highlight_string() and highlight_file()

As for a tutorial on Geshi, I have not looked for one, so I don't know.
Erfangc
Forum Newbie
Posts: 11
Joined: Sat Jul 29, 2006 2:21 pm

Post by Erfangc »

thanks for the reply.
After reading the documentation on GeSHi I believe it is unnecessary for any additional tutorials.
Erfangc
Forum Newbie
Posts: 11
Joined: Sat Jul 29, 2006 2:21 pm

Post by Erfangc »

strange, the following code caused the $source to be outputed first.

Code: Select all

$row = mysql_fetch_array($results);
$content = $row['content'];
$title = $row['title'];
echo "<tr><td><p><font size='+6'>".$title."</font></p></td></tr> ";
echo str_replace("\t", '&nbsp;&nbsp;', nl2br("<tr id='content_area'><td>".$content."</td></tr>"));
$source =
"//source";
$lan = 'java5';
			
$geshi =& new GeSHi($source, $lan);
			
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
echo $geshi->parse_code();
Post Reply