Thread: [code] coloring breaks [color]

  1. #16
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    Code:
    PHP Code:
    int mainvoid ) {     int x// not initialized     printf"x is uninitialized, yay! %d\n");     return 0; } 
    See? That's a [php] tag. Why don't you just use that for code coloring? Anyway, [pre] is a good idea too. But we already have had syntax coloring forever with [php]


    Quzah.
    Well heck... lets just do that! Saves everyone a ton of work...
    Just need to get rid of the "Please use code tags warning" and we're all set...

  2. #17
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by CommonTater View Post
    Well heck... lets just do that! Saves everyone a ton of work...
    Just need to get rid of the "Please use code tags warning" and we're all set...
    The funniest part of this whole thing is people crying about the PHP tag when it was first introduced ... because it colored everything. People, and I won't mention any names, got pretty upset about people using the PHP syntax coloring. It's pretty hilarious now that they are trying to actually get it colored by default.

    PS to you know who you are: No, I'm not talking about what you think I'm talking about, I'm actually talking about the PHP tags.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #18
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Just a thought... I don't know if this is possible...

    Can you rename a BB code tag?

    If so rename the PHP tag CODE
    rename the CODE tag PRE

    real easy fix.... if it's possible.

  4. #19
    Administrator webmaster's Avatar
    Join Date
    Aug 2001
    Posts
    1,012
    @quzah Yeah, I know about the PHP tag, but I don't particularly like them since it's doing PHP coloring and not C++, so the results aren't going to be as accurate. (I also don't particularly like the choice of colors although I imagine that must be configurable somewhere.)

    @CommonTater If we were going to use php tags, I'd simply change the board to treat [code] blocks as PHP highlightable code, rather than having folks use php tags manually. The value of automatic highlighting is to make it consistent and apply to older posts in addition to new posts. I don't see the value of the [pre] idea--the choice of whether code should be highlighted should belong to the reader, not the poster, unless the poster wants to do some kind of special highlighting.

  5. #20
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by webmaster View Post
    I also don't particularly like the choice of colors although I imagine that must be configurable somewhere.
    It seems like it should be. It's got to have a list some place of what it uses for what keywords.
    Quote Originally Posted by webmaster View Post
    I don't see the value of the [pre] idea--the choice of whether code should be highlighted should belong to the reader, not the poster, unless the poster wants to do some kind of special highlighting.
    What's that you were saying?


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #21
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by webmaster View Post
    @quzah Yeah, I know about the PHP tag, but I don't particularly like them since it's doing PHP coloring and not C++, so the results aren't going to be as accurate. (I also don't particularly like the choice of colors although I imagine that must be configurable somewhere.)
    With respect... if there's a ready-to-use answer on hand I don't see the problem. The other highlighter was rather, um, kludgey requiring browser refresh and redraws to make it show up... I'm thinking this might be a good time to just take the path of least resistance...

    @CommonTater If we were going to use php tags, I'd simply change the board to treat [code] blocks as PHP highlightable code, rather than having folks use php tags manually.
    Exactly... that was why my (perhaps clusy) suggestion of simply renaming tags... I think we agree on this point.


    I don't see the value of the [pre] idea--the choice of whether code should be highlighted should belong to the reader, not the poster, unless the poster wants to do some kind of special highlighting.
    Ummmm.... not sure what you mean or how you would do that. One might reasonably expect that highlighting should be the default unless the reader wants to turn it off in their settings... The pre idea was taken from the HTML PRE tag that allows preformatted text... adding that, by whatever name, gives the poster the choice to highlight or not...

    Just thinking out loud... but if it's not too much trouble to rewire the code tags to act like php, how about we give it a try?
    Last edited by CommonTater; 09-20-2011 at 09:50 PM.

  7. #22
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by webmaster View Post
    Thanks for all the feedback!

    Here's my current thinking:

    1) Make it so that code regions that are hand-colored by users (in any way) are ignored by the highlighter. If this works, I'm not sure it will be necessary to have a separate [code=plain] option.
    2) The colors need to be tweaked. I'll work on this once the breakage issues are resolved.
    3) I also like the idea of having an option to disable the highlighting for users who don't want it. Either a per-code-box button or a user setting.
    4) The contexts where it doesn't currently work need to be fixed--lower priority for now, as long as #1 is resolved satisfactorily.

    For the moment, I am going to disable highlighting until I've fixed issue #1 and then, once resolved, try to get reasonable colors.
    Is there a way to add to this "to do" list? Such as along with code coloring, an auto format (e.g. indent) tool? I can't imagine this would be too hard to add to the parser, and it would save a lot of time trying to decipher some posts. Many times it is in fact that the OP doesn't know how to indent, however there are also many examples of the formatting being broken when the code is copied and pasted from the editor. "The whitespace disaster phenomenon". This could be resolved by auto-formatting, however I am not sure of the overhead this would create for the sites wrt post times and all that other stuff I am not familiar with.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  8. #23
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    Quote Originally Posted by AndrewHunter
    an auto format (e.g. indent) tool? I can't imagine this would be too hard to add to the parser, and it would save a lot of time trying to decipher some posts. Many times it is in fact that the OP doesn't know how to indent, however there are also many examples of the formatting being broken when the code is copied and pasted from the editor. "The whitespace disaster phenomenon". This could be resolved by auto-formatting,
    How would that handle different indent styles? Or are you proposing that an indent style be mandated?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #24
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by laserlight View Post
    How would that handle different indent styles? Or are you proposing that an indent style be mandated?
    It would have the side effect of mandating an indent style, however if you can turn off the highlighting you could do the same with the indentation. I was looking at a way to avoid posts where the code winds up all across the board like this and this thread. That way the responders can focus more on the problem at hand; you have to admit that some posts are just down right unreadable.

    As for which style to choose, I would imagine something that was close to "How to indent code" would be both easy to implement programatically and shouldn't be too much of a matter of debate. Both you and I, as well as many others, have reformatted posts prior to addressing issues; I wouldn't see why we wouldn't want to alleviate that problem.

    EDIT: Note that the link is not my chosen indentation style, so I am not "playing favorites" here.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  10. #25
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Hi Andrew... the only problem with your suggestion is that it really doesn't help people develop their own coding skills...

    Sad fact... when things are done for people, they soon enough don't want to do it for themselves.

    Me... I'd be happy just to see line numbers!

  11. #26
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by CommonTater View Post
    Hi Andrew... the only problem with your suggestion is that it really doesn't help people develop their own coding skills...

    Sad fact... when things are done for people, they soon enough don't want to do it for themselves.

    Me... I'd be happy just to see line numbers!
    I agree, however I do not think it would rob them of learning how to indent; just not on this board. Either way, it was just a suggestion to alleviate some formatting issues. I can just as easily make a little app to do it for me if the popular opinion here is that no one sees an advantage to it.

    BTW, Hi Tater!
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  12. #27
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    Quote Originally Posted by CommonTater
    Me... I'd be happy just to see line numbers!
    Me too. There would no "user preferences" to consider, and we get to refer to line numbers without confusion.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  13. #28
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by laserlight View Post
    Me too. There would no "user preferences" to consider, and we get to refer to line numbers without confusion.
    Exactamundo!

  14. #29
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by CommonTater View Post
    Hi Andrew... the only problem with your suggestion is that it really doesn't help people develop their own coding skills...

    Sad fact... when things are done for people, they soon enough don't want to do it for themselves.

    Me... I'd be happy just to see line numbers!
    Quote Originally Posted by laserlight View Post
    Me too. There would no "user preferences" to consider, and we get to refer to line numbers without confusion.
    As long as the line numbers were embedded with the formatting so we could still just do a direct copy and paste into an IDE. As for anything else, I don't mind either way; I will just add a formatting option to the highlighter I use and keep on doing what I have been.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  15. #30
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The version they have (had?) in place now with [code] does line numbering, and you can even click-drag-copy-paste and it won't add the line numbers. It's pretty nice (except for having to shift+reload to get it to show up) except for the color choices.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Switching from MinGW to Pelles C, code breaks
    By Hear.Me.ROAR in forum C Programming
    Replies: 4
    Last Post: 08-11-2011, 11:21 AM
  2. my code breaks unique pointer rule?
    By George2 in forum C++ Programming
    Replies: 19
    Last Post: 02-17-2008, 03:26 AM
  3. Code-Coloring
    By Vber in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 01-08-2003, 11:29 PM
  4. Paste code into word keeping color
    By GaGi in forum C++ Programming
    Replies: 1
    Last Post: 02-07-2002, 08:26 AM