I can't believe how difficult it is to post a question on Stack Overflow. I keep getting the following message:

Oops! Your question couldn't be submitted because: Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button

I indented every piece of code according to the specifications. I don't know why it's giving me that message. Here are screenshots of what I'm trying to enter.

I spent a lot of time trying to format my post to your specifications, but can still not get it posted. What might cause this and what can I do about it?

  • 5
    Can you show us a screen shot of the editor screen with the post you're trying to enter? – Ernest Friedman-Hill Jul 18 '12 at 12:19
  • 2
    Or alternatively, post your (rejected) question to a pastebin and share it here. – Martijn Pieters Jul 18 '12 at 12:20
  • 2
    Are you sure that all your code is properly formatted? – ChrisF Jul 18 '12 at 12:21
  • 2
    I know - only 3.3m questions managed to get posted successfully so far. Did you stop to consider that the problem might be you? – Widor Jul 18 '12 at 12:22
  • @Ernest --- yes I will, give me a few minutes to do it. – Michael Swartz Jul 18 '12 at 12:23
  • Also thousands of people seem to satisfy the requirements for posting questions every day. So instead of moaning and WTF'ing maybe you could provide some actual details so we can show you what you're doing wrong. – Aaron Bertrand Jul 18 '12 at 12:23
  • 25
    Looking at the quality of questions in SO I think posting them is too easy. – Tadeusz Kopec Jul 18 '12 at 12:23
  • top part: i48.tinypic.com/2mxmzcp.jpg<br> bottom part: i50.tinypic.com/b4uble.jpg<br/>the python code is indented 4 spaces according to the specifications – Michael Swartz Jul 18 '12 at 12:30
  • You should not quote the data, but rather format it as code, too. Quote will not preserve new lines. – Time Traveling Bobby Jul 18 '12 at 12:31
  • 1
    So format the data as code even though it is NOT code? Is that the answer? – Michael Swartz Jul 18 '12 at 12:34
  • 3
    The quoted data in the bottom part should show up as a single-line jumble in the preview. That's a big sign that the system will reject it, since it's rarely what the user intends. (It might accept it if you used two spaces at the end of each line to manually insert line breaks, but for JSON you'd be more expected to just code block it.) – Jeremy Banks Jul 18 '12 at 12:38
  • 2
    I suggested a, ummm, less-inflammatory title. In general, keeping the question (which is very appropriate) but editing out the frustrated antagonism (which is less so) would be nice :) – Ziv Jul 18 '12 at 12:40
  • 1
    Your file content is still not formatted as code. With it containing lots of numbers and ';' that is most likely still tripping it up. – Bart Jul 18 '12 at 12:57
  • 2
    I would like to add one more thing that falls back to my original yet highly edited for content question. Just because it looks like code doesn't mean it is code. If it was code I would have formatted that way but my intent was to have it appear as text because that is exactly what it was. Those parts that had to be formatted as code needed to stand out from the actual code, not look like code. Having to try and figure that out made this harder than it needed to be. So the rhetorical question is how do you allow that without people getting lazy and just trying to pass everything off as text? – Michael Swartz Jul 18 '12 at 13:33
  • 1
    "So format the data as code even though it is NOT code?" The data should be formatted and display as a literal just like the code should be formatted and displayed as a literal, so yes it should be. – dmckee Jul 18 '12 at 17:20

One of your screenshots says how to fix the problem:

Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut

They look similar, but there's a difference between a blockquote, which starts with a >:


and a code block, which starts with four spaces:

code block

If you need to add two spaces to the end of each line to make it wrap, you're using a blockquote; code blocks don't work that way. See the source of this post if that helps

  • The root cause here is that the text that needed to be formatted as code wasn't actual code, so the error message was completely misleading. – Mark Ransom Jul 18 '12 at 16:17
  • @MarkRansom Maybe so, but the question was "what can I do about it". It's pretty common to use code blocks for things other than code; it's more like a verbatim block – Michael Mrozek Jul 18 '12 at 17:00
  • You provided the what but not the why, which leaves the answer less useful than it could be. "It's pretty common" - yes it is, but that wouldn't be known to someone new to the site. – Mark Ransom Jul 18 '12 at 17:07

For a general answer, a good place to look for why your post might be tripping the "code formatting" filter is this Programmers.SE question:

Simple method for reliably detecting code in text?

That's a question Jeff Atwood (co-founder of Stack Exchange) asked when they were implementing this feature. It looks like your data (that you have in blockquote formatting) would trip a few of those simple checks, especially

  • "A dot or arrow between two words",
  • "Presence of curly braces, brackets",
  • "Uncommon characters/operators", and
  • "nested parentheses, braces, and/or brackets"

Also, see this search query:

"your post appears to contain code that is not properly formatted as code" (sorted by votes)

The questions there have explanations of the filter. There are also posts by other people that have had similar problems, and how their specific situations were resolved.

You must log in to answer this question.

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