Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

It seems a common occurrence that new users to the site post their code without an extra indent, leading to stuff looking like this:

import os import sys

def foo(): print 'hi'

return os.listdir('.')

etc... people then usually implore the user to fix it in the comments, or someone will come along and fix it for them.

Feature request: infer whether code without an extra level of indent is possibly being posted. If so, when you click 'post your question', it will ask you explicitly: "Make sure that if you are posting code, it is properly indented." You have to click again to submit the question.

This might lead to false positives. To minimize annoyance, this will only apply to new users, or users with < a certain amount of rep. This is based on the assumption that only new users tend to do this.

The benefit is less poorly formatted questions, woohoo.

share|improve this question
This is especially possible for HTML questions. I've been thinking of making this request myself. – SLaks May 19 '11 at 19:40
I suspect that the question-rejecter balks at unformatted code. – SLaks May 19 '11 at 19:40
rather than letting them make a post that looks like a mistake, it seems a good solution to ask them whether they're sure that the question looks like they want it to look like. – Claudiu May 19 '11 at 20:24
"Sorry, we can't accept your question. Because you are a slackadasical." – Won't May 19 '11 at 20:47

I seriously had to resist the compulsion to edit this question and fix the code sample...

And along those same lines, I don't think this is actually a problem for which we need a solution. In my experience, new questions get edited very quickly by other users to fix these types of mistakes. Automatically "inferring" formatting is likely to cause way more problems than it solves. When I enter text in my answer, I expect it to appear just like I entered it, without it being subjected to an algorithmic determination of whether or not it looks like "code".

As Jeff says, posts that are incorrectly formatted should (and in fact, currently do) look wrong:

This would lead to users pasting in unformatted code and getting away with it.

Instead, I want mistakes in the post to look like mistakes.

(and yes, I consider a "missing content" post one that looks like a mistake.. )

The real solution is getting users to pay enough attention to and spend enough time on the questions they're asking to notice in the preview pane that their code is incorrectly formatted and their question is unreadable. Then, they're likely to pursue alternative solutions, like reading the markdown formatting guide which tells them explicitly how to format code in a post.

If they don't care enough to fall into this category, well, there's always the "close" button, and it doesn't much care how/if the code is formatted.

The benefit is less poorly formatted questions, woohoo.

share|improve this answer

You must log in to answer this question.

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