Da Warriah
04-21-2003, 08:01 PM
ok, im helping one of my friends out with a website about C# (which i know nothing about, im just the webmaster, lol)...anyways, for his tutorials, he wants some syntax highlighting, like changing the colors for different keywords...this is to be done in PHP, and i have the basic script laid out, but im stumped with one thing: comments...
everythings fine with multiline comments, such as
/* this is a
multiline
comment */
but when i get to one line comments, i cant think for the life of me, how to end the highlighting at the end of the line...heres my code so far:
$tut = str_replace("//","<span class=\"kw2\">//",$tut);
$tut = str_replace("<||>","</span>",$tut);
that works fine, but every time someone wants to write a comment, they will have to put a <||> at the end of it...which is not what i want to happen...so is there any way to replace a line break with a </span> tag, but ONLY after it has replaced the double slash?? any help would be GREATLY appreciated here...
everythings fine with multiline comments, such as
/* this is a
multiline
comment */
but when i get to one line comments, i cant think for the life of me, how to end the highlighting at the end of the line...heres my code so far:
$tut = str_replace("//","<span class=\"kw2\">//",$tut);
$tut = str_replace("<||>","</span>",$tut);
that works fine, but every time someone wants to write a comment, they will have to put a <||> at the end of it...which is not what i want to happen...so is there any way to replace a line break with a </span> tag, but ONLY after it has replaced the double slash?? any help would be GREATLY appreciated here...