RE: [PHP] How does the PHP website colorize the code snippets?
| From: | Daevid Vincent | Date: | Thu, 15 Nov 2007 11:40:32 +0000 |
| Subject: | RE: [PHP] How does the PHP website colorize the code snippets? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-264560@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: T.Lensselink [mailto:dev@lenss.nl]
> Sent: Thursday, November 15, 2007 12:05 AM
>
> On Wed, 14 Nov 2007 23:45:40 -0800, "Daevid Vincent" <daevid@daevid.com> wrote:
> > I want to put a code snippet section on my site and want to
> > colorize them like the user comments on any PHP site page.
> >
> > ," Oh٨4
> > hZÏ*%http://www.php.net/manual/en/language.operators.arithmetic.php
> >
> > What's the easiest way to do that?
> >
> > I've used Geshi, but that seems a lot of overhead just to
> > colorize a wee bit-o-PHP code.
> Take a look at highlight_string or highlight_file.
>
> http://nl3.php.net/manual/en/function.highlight-string.php
> http://nl3.php.net/manual/en/function.highlight-file.php
Worked pretty good. It seems to have trouble with the \ and \\ chars for some reason, but close
enough for jazz as they say... (notice the array has \\ when it should only be a single one, however
if I get that to work, then the color coding after it is messed up and the \n don't show up.
Grr.)
Czech out http://daevid.com "Free Code > Code
Snippets"
I think the little curled corners are slick too!
PHP.net, you're free to borrow my idea/CSS for your website if you like :D
Now if only the colorize/highlight functions worked on other types of source code (ruby, bash,
procmail, etc)... Maybe I'll just have to use Geshi afterall...
D.Vin