What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 134 Stack Exchange communities.

Sometimes code is included in an answer in order to show what not to do. For example:

String foo = null;
String.IsNullOrEmpty( foo.Trim())

...Throws an exception as foo is Null.

The correct code is usually listed later in the answer. In the interest of preventing careless visitors from quickly copying and pasting the code the author didn't want them to use, it would be nice if there was a way to mark bad or dangerous code so the background was a light red color instead of grey (for example).

As an example of how this could be automatically displayed, when the first line of a code block is a comment with a particular message, the code block's background would be changed, or perhaps a little warning triangle icon would be added.

Trigger possibilities:

// Bad code
/* Dangerous code */
# Incorrect code

Just an idea.

share|improve this question
1  
Related (and far more generic, and hence more useful in my opinion): Allow highlighting certain bits of a code fragment or quote. –  Arjan Mar 11 '11 at 16:51

1 Answer 1

If people are just blindly pasting code without thought or care they kind of deserve what they get, don't you think? It might sound harsh but I definitely don't want that coder writing stuff that I'm going to use or maintain.

A way to highlight code manually might be useful though.

share|improve this answer
1  
I still think the suggestion would be useful, just not for the same reason. If your first block of (bad) example code is clearly marked, it might stop people from downvoting without finishing reading your answer. –  Bill the Lizard Mar 12 '11 at 20:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .