Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Feature Request: Adding Colors to Source Code

by Vautrin (Hermit)
on Mar 07, 2004 at 20:21 UTC ( #334653=note: print w/ replies, xml ) Need Help??


in reply to Re: Feature Request: Adding Colors to Source Code
in thread Feature Request: Adding Colors to Source Code

Well, that's the thing, I don't think I should have to go through hoops to read the code someone has posted. Syntax highlighting is much more convinient. A good example is php.net. I don't code in PHP often (except when I have to), but when I do, any examples are much easier to read -- especially the verbose ones. Besides, I don't always have a lot of time when I'm on Perl Monks. The extra effort required to view noob code sometimes means I don't have the time to spend on it.


Want to support the EFF and FSF by buying cool stuff? Click here.


Comment on Re: Re: Feature Request: Adding Colors to Source Code
3Re: Feature Request: Adding Colors to Source Code
by jeffa (Chancellor) on Mar 08, 2004 at 13:21 UTC

    So you would rather someone else go through hoops instead, eh? I call that false lazyness. First of all, some of us don't even need syntax highlighting - i for one do use it, but i do not rely upon it. When i was cutting my teeth here at Perlmonks i didn't complain about not having enough time to review "noob" code ... i just ran their code through perltidy and rolled with it. It's up to me to find the time.

    It's really quite simple you see, this kind of feature is one that you yourself can implement. Just write a CGI script that accepts a number as it's single param and fetch that node from Perlmonks with displaytype=displaycode. Run through the code through one of the many CPAN modules mentioned and display. Personally, i think this should be a requirement before one can become a Friar. ;)

    UPDATE: One time only? Maybe if you are God ... but most of us mere mortals have to rely on testing and debugging before we get it right. And the more users you have to accomodate for, the more testing and debugging required. Not to mention the committee that must be assembled to agree upon what to implement and what to reject. Give your client an inch and they will want a mile.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    

      So you would rather someone else go through hoops instead, eh? I call that false lazyness.

      One time only. After that, the machine goes through hoops for us. I'd add the feature myself if I could because IMHO this is the single most important feature missing here.

      some of us don't even need syntax highlighting

      Those who don't need it can still benefit from it. Those who don't want it aren't hurt in any way except a little bandwidth. This feature only adds something to the site. Code to implement it is freely available. I just hope someone will spend a few minutes to implement it.

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

        I'm having a hard time to find a few minutes to reply to the large number of incorrect assertions in this thread.

        Nodes are not rendered before they are inserted into the database and making that happen even in part is no simple task. It will never happen in total as there are user settings that affect how nodes are to be rendered. Doing some partial rendering and having to keep multiple versions of each node in sync sounds like a complex design that, in my experience, would lead to a lot of unintended complications.

        So the increased load will not be per node update as you appeared to assume but per node display. This would probably be a significant load even if we went with the faster but worse of your suggested solutions.

        There is no code to do syntax highlighting that also works with PerlMonks code wrapping options. Having the two behave together would not be trivial work.

        It is nice that you think you won't mind having non-Perl or pseudo-Perl be highlighted incorrectly. Try to think about other people for second. Do you really think everyone who posts some code related to their problem will just shrug and say "no point in complaining about the whacky colors being forced upon my input, it is a tiny price to pay for the wonder that is syntax highlighting and I'm so happy I have that"?

        Yes, please, let's add a <perl> or <code type="perl"> tag to a mark-up system that people are already complaining is too complicated. For one thing, I won't be wasting my time trying to decide whether the code I post is suitable to be highlighted or not so my code will remain in plain CODE tags and wouldn't be subject to highlighting. So we'll get to enjoy lots of whining and considering and janitorial thrashing arguing about whether each bit of code should be marked for syntax highlighting or not and whether janitors should be making such changes.

        And you want us to use the acknowledge worse of a couple of syntax highlighters. Syntax highlighting is a fine compromise to make with yourself. You imposed the somewhat broken highlighter upon yourself so you can choose whether it is a net win for you to avoid the constructs that confuse it or to remove the broken highlighter. Having someone else choose a syntax highlighter for you is going to be a source of conflict. Even the best syntax highlighter doesn't get all Perl code right. I really don't look forward to the volume of complaints about code being highlighted incorrectly.

        I find it very inappropriate to have PerlMonks not support certain Perl constructs because they get highlighted incorrectly (and some will interpret it that way either criticizing people for posting such constructs and not checking that the code they posted was highlighted correctly or criticizing PerlMonks for not highlighting their code correctly).

        I often post Perl pseudo code which I'm sure some will be completely unable to read without their pretty colors assigned to bits yet the highlighter won't be able to parse because I wrote "You'll need to insert code here" and every reader can understand what I meant but no syntax highlighter does.

        So, since you find this such trivia to provide, then write an external solution such that clicking "download code" pops up a web page containing highlighted Perl code. A user setting to contol the Content-Type as suggested by hossman might be helpful. Or you could write it as an HTTP proxy and even implement Vautrin's trivial automatic Perl code detector so that only Perl code gets highlighted (and it wouldn't be limited to just PerlMonks).

        Since this is such a vital feature, I'm really surprised that you haven't implemented this already. It will just take you a couple of minutes, I'm sure.

        - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://334653]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2014-08-22 14:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (158 votes), past polls