Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Code Highlighting in the code tag

by mischief (Hermit)
on Aug 09, 2001 at 23:19 UTC ( #103582=monkdiscuss: print w/replies, xml ) Need Help??

How hard would it be to implement some kind of code highlighting for anything inside the <code> tag? Does anyone know of any perl-to-html code highlighting module type thing?

Replies are listed 'Best First'.
Re: Code Highlighting in the code tag
by mirod (Canon) on Aug 10, 2001 at 01:54 UTC

    Such a scheme would have to be optional of course, as I don't think highlighting an obfuscation would be such a good idea (on top of being probably quite difficult!)

Re: Code Highlighting in the code tag
by spudzeppelin (Pilgrim) on Aug 10, 2001 at 03:08 UTC

    It sounds like an interesting exercise, but one that wouldn't be particularly nasty: there are already syntax-coloring filters for perl out there (consider that both vim and cooledit have them, and cooledit has the peculiar misfortune of being written in python). It shouldn't require much more than turning the ANSI escape sequences in the syntax-highlighting routines in vim into the corresponding <SPAN> tags in HTML. Getting <SPAN> recognized inside of <CODE> is another matter altogether -- <CODE> is designed to indicate to the browser that as much as possible within the block is to be treated literally.

    Spud Zeppelin *

      Using <code> tags in your post doesn't actually put a <code> tag in the html output when you view it (check the source). One of the reasons I suggested it is because there's already some kind of magick going on with <code> tags, so I figured that it might be as easy as putting in a sub for the code highlighting along with $code = highlight_code($code) if $user_prefs{'wants_highlighting'} in the bit that deals with the code. (Dammit! I've got <code> on the brain now after using it 16 times in this post. :-)
      While we're discussing syntax coloring in editors, Glimmer has syntax coloring since way before it was called Glimmer. But then again, what use is that in the Monastery? Looking into PerlTidy is probably a good thing.

      ... Quidquid perl dictum sit, altum viditur.
Re: Code Highlighting in the code tag
by kevin_i_orourke (Friar) on Aug 10, 2001 at 17:57 UTC
Re: Code Highlighting in the code tag
by bikeNomad (Priest) on Aug 10, 2001 at 18:48 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://103582]
Approved by root
[choroba]: I want to present the most bizzare bugs and misfeatures I met when working for a large financial institution
[choroba]: I already gave a similar talk to my friends in a pub and at an internal conference at work and people liked it, so maybe...
[choroba]: LanX: That's the heritage, I can't do anything else
[RonW]: Sounds like some system my employer has "It does exactly what we need it to do and can't afford to risk anything we can't prove is 100% compatible"
[marto]: choroba sounds interesting
[RonW]: james28909 Why not write a Perl program to do the task?
[choroba]: RonW Yes, but then, one day, they needed to switch from FTP to SFTP, and... but I can't give the whole talk away here :)

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2017-05-22 21:39 GMT
Find Nodes?
    Voting Booth?