in reply to syntax highlighting of code in perlmonks forums

I like the idea, and even think it'd be good if this were enabled by default. Just not with the colours that you propose; they burn holes in my screen :)

Not everything in code-blocks is Perl source, but I see no harm in trying to render it as such. After all, only colour changes, not the text itself. Does it matter if some non-code is coloured differently?

Perhaps the Monastery could add <span> tags automatically so that people who want colours can put some colour definitions in their personal CSS. That wouldn't change anything for users that think colours are "gay".

One problem could be server load, but I don't know how well Everything caches, so I can't say much about that. I do know that on my box, Syntax::Highlight::Perl performs better than Perl::Tidy. It isn't as good, though, but I can live with the results. My Scribble service uses S::H::P, and I copied your code so you can have a look at how S::H::P does it: http://tnx.nl/scribble/765WQMX (link dies in 30 days). Colours are not hard coded, but in an external CSS file. Disable CSS and the colours are gone. Ideal, IMO.

Horrible code, by the way...

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

  • Comment on Re: syntax highlighting of code in perlmonks forums

Replies are listed 'Best First'.
Re^2: syntax highlighting of code in perlmonks forums
by f00li5h (Chaplain) on Jan 06, 2007 at 11:39 UTC

    I'm a massive fan of using the particular monk's CSS to determine the hilighting... and providing a seperate option to enable it. (disabled by default)

    Perhaps also providing a couple of default styles to get you started, a nice light-on-dark, a dark-on-light etc

    even if it was just based on css, without an off switch

    .codeblock { background-color: inherit!important; color:inherit!important; }
    and boom, the hilighting disappears... and it starts looking like normal text (black on white) Or you could even do something outragious and provide a real user stylesheet to your browser to over-ride these things...
    @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;