6

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.

5
  • This is especially possible for HTML questions. I've been thinking of making this request myself.
    – SLaks
    May 19, 2011 at 19:40
  • I suspect that the question-rejecter balks at unformatted code.
    – SLaks
    May 19, 2011 at 19:40
  • 1
    meta.stackexchange.com/questions/85886/…
    – balpha StaffMod
    May 19, 2011 at 20:02
  • 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, 2011 at 20:24
  • 3
    "Sorry, we can't accept your question. Because you are a slackadasical."
    – user1228
    May 19, 2011 at 20:47

1 Answer 1

2

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.

You must log in to answer this question.

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