Gossamer Forum
Home : Products : Gossamer Forum : Development, Plugins and Globals :

Perl Code Highlighter Plugin Complete

Quote Reply
Perl Code Highlighter Plugin Complete
I decided to post a new thread to keep things clear.

The plugin to colorize code is finished.

You can see a demo here:

http://213.106.15.150/...m/gforum.cgi?forum=1

All colors are controlled by the administrator using the plugin manager. Here's a brief summary of how it works....

Using [code] something [/code] will show normal black code still.

[pretty] something [/pretty] will show colorized code but as it is a pre/first hook then I've got it to return the colorized code inside a [code] tag which is then parsed by GForum so you keep the formatting of [code] tags.

The [pretty] [/pretty] tags are also admin controlled so you can change them to whatever you want.

I'm going to get Alex or Jason to "hopefully" add it to their server and *ideally* I'd love them to install it here Angelic

I'll reply to this post once Alex has let me know whether he'll add it to the server or not.

Last edited by:

RedRum: Feb 13, 2002, 8:23 AM
Quote Reply
Re: [RedRum] Perl Code Highlighter Plugin Complete In reply to
Change the tags to [perl] and [/perl] :-) Sounds better than "preety".

Did you look at the site URL I posted for you?

I get a fatal error on the above URL, BTW.

- wil
Quote Reply
Re: [Wil] Perl Code Highlighter Plugin Complete In reply to
>>
Change the tags to [perl] and [/perl] :-) Sounds better than "preety".
<<


Quote:
The [pretty] [/pretty] tags are also admin controlled so you can change them to whatever you want.

Quote Reply
Re: [RedRum] Perl Code Highlighter Plugin Complete In reply to
Looks nice! Personally, I'd prefer a fixed width font (like courier), but I suppose I can change that easily...

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Perl Code Highlighter Plugin Complete In reply to
>>Personally, I'd prefer a fixed width font (like courier), <<

After colorization it is returned inside [code] tags so it uses the same formatting as [code] [/code] otherwise it looks ugly.

Last edited by:

RedRum: Feb 13, 2002, 8:02 AM
Quote Reply
Re: [yogi] Perl Code Highlighter Plugin Complete In reply to
Feel free to play about at the url above. Guest posting is on.
Quote Reply
Re: [RedRum] Perl Code Highlighter Plugin Complete In reply to
Hi Paul,

How did you end up doing the parsing? Something you did yourself, or use a module? I would definately default it to [perl] unless it parses php code as well. =)

Quote:
[pretty] something [/pretty] will show colorized code but as it is a pre/first hook then I've got it to return the colorized code inside a [code] tag which is then parsed by GForum so you keep the formatting of [code] tags.


You could just wrap it in the same table that code does. Would save having to parse it twice, as long as you let the admin change the html.

But sure, send it over and I'll add it to the site.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Perl Code Highlighter Plugin Complete In reply to
Hi,

Ideally I would have liked to have written the code myself and did start off doing it that way, but I decided to save myself the time and effort and integrate a CPAN module Smile.

>>I would definately default it to [perl] unless it parses php code as well. =) <<

Well because the syntax between perl and php is "similar", it does parse to a certain degree. See the demo below:

http://213.106.15.150/...post_view&post=7

The plugin is on its way to you via email. Thanks.

Last edited by:

RedRum: Feb 13, 2002, 12:28 PM
Quote Reply
Re: [RedRum] Perl Code Highlighter Plugin Complete In reply to
Hmm may help if I install the plugin :)
Quote Reply
Re: [yogi] Perl Code Highlighter Plugin Complete In reply to
The plugin can now be downloaded from you GForum admin panel.

Thanks everyone.
Quote Reply
Re: [RedRum] Perl Code Highlighter Plugin Complete In reply to
Just thought I'd mention the plugin was added to http://perlguru.com by Jasmine Smile
Quote Reply
Re: [RedRum] Perl Code Highlighter Plugin Complete In reply to
Good job. You should really change that green to a darker color though! ugh.

- wil
Quote Reply
Re: [Wil] Perl Code Highlighter Plugin Complete In reply to
And a very cool hack would be to have the option to add line numbers into the code. See the URL I sent you in earlier post - code2html.

- wil
Quote Reply
Re: [RedRum] Perl Code Highlighter Plugin Complete In reply to
I've updated the plugin.

There are two lots of default tags now.

[perl] [/perl]

and

[nperl] [/nperl]

The perl tag does normal colorizing and nperl includes line numbering.

Demo:

http://213.106.15.150/...post_view&post=8

The number font color is set in the plugin options by changing the "Numbers" option.

Last edited by:

RedRum: Feb 15, 2002, 2:52 AM
Quote Reply
Re: [RedRum] Perl Code Highlighter Plugin Complete In reply to
Hm, can the line numbers be black instead of red? :-)

You've done a good job here, Paul! Cograts. I could get used to this; I supply the ideas and someone else codes them ;-)

Rgds

- wil
Quote Reply
Re: [Wil] Perl Code Highlighter Plugin Complete In reply to
Oh, and remember to put a blank space in front of number < 10 to keep the formatting consitent when the line numbers => 10.

Cheers

- wil
Quote Reply
Re: [Wil] Perl Code Highlighter Plugin Complete In reply to
>>
Hm, can the line numbers be black instead of red? :-)
<<

Quote:
The number font color is set in the plugin options by changing the "Numbers" option.


>>
I could get used to this; I supply the ideas and someone else codes them ;-)
<<

Sorry to burst your bubble but it was in the pipeline before you mentioned it Smile

>>
Oh, and remember to put a blank space in front of number < 10 to keep the formatting consitent when the line numbers => 10.
<<

View the demo.

Last edited by:

RedRum: Feb 15, 2002, 4:19 AM
Quote Reply
Re: [RedRum] Perl Code Highlighter Plugin Complete In reply to
As I already said, nice work.

But, be aware of one thing: page size. The colouring makes for much bigger pages, and consequently more download time.

Example:

gforum.cgi as [code], size 15 kb
http://213.106.15.150/.../gforum.cgi?post=23;

gforum.cgi as [perl], size 40 kb
http://213.106.15.150/.../gforum.cgi?post=22;

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Perl Code Highlighter Plugin Complete In reply to
Yep,

Thats why its good to have the code tag still in there. The perl tag should be used occassionally to highlight something or only with small code snippets.

Last edited by:

RedRum: Feb 15, 2002, 4:44 AM
Quote Reply
Re: [RedRum] Perl Code Highlighter Plugin Complete In reply to
Hm, funny why you never mentioned this.

- wil
Quote Reply
Re: [yogi] Perl Code Highlighter Plugin Complete In reply to
This is where CSS comes in handy. Just add some css to the header (or include it):
Code:
.var {
color: #000000;
}
...

Then to make things smaller, you can do a little 'ugly' html.
<a class=var>$foo</a>

You can make all of this even more compact, by doing some ugly css (combined with some ugly html):
Code:
<style type="text/css">
#var{color:#000000}
</style>
<a id=var>$foo</a>
Ugly, but small, and technically valid html / css.

Adrian
Quote Reply
Re: [RedRum] Perl Code Highlighter Plugin Complete In reply to
Oops posted in the wrong thread before....

The bug mentioned here:

http://www.gossamer-threads.com/...;;page=unread#unread

...is now fixed I *hope* and the updated plugin can be downloaded from admin.