RE: [PHP] How does the PHP website colorize the code snippets?
| From: | T . Lensselink | Date: | Thu, 15 Nov 2007 13:33:41 +0000 |
| Subject: | RE: [PHP] How does the PHP website colorize the code snippets? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-264563@lists.php.net to get a copy of this message | ||
On Thu, 15 Nov 2007 03:40:32 -0800, "Daevid Vincent" <daevid@daevid.com>
wrote:
>> -----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.
>> >
>> > http://www.php.net/manual/en/language.operators.arithmetic.phpôs1ú
>> > ÓÏœ2ÌÓï�
>> >
>> > 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"
Looks good. I also didn't get the exact result i was looking for. But hey..
it's a start.
>
> 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
Dragable boxes are nice. Wish i had some time to work on my site :)
>
> 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...
If you are looking for code highlighting for all those languages maybe take
a look at
http://www.gnu.org/software/src-highlite/.
>
> D.Vin
gr,
Thijs
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php