22

A few moments ago I encountered a pretty annoying bug with the code detection and the preview-function, when I wanted to post an answer. While the preview looked like this:

Some Title

code that was below the title

text explaining the code

using this text in my answer:

*Some Title*
--
    code that was below the title
*text explaining the code* 

It kept refusing to post the answer and telling me:

Your post appears to contain code that is not properly formatted as code. Please indent all code ...

Looking at the preview, everything looks fine and formatted as it should be.

What am I missing that causes this error and how should I resolve this error?

2
  • 4
    You need an empty line before a code block, always.
    – Martijn Pieters Mod
    Commented Feb 15, 2018 at 14:15
  • 4
    @MartijnPieters That's almost true. You don't need a blank line before the code block, if the code is the first line in the post.
    – Makyen Mod
    Commented Feb 16, 2018 at 6:52

1 Answer 1

19

It took me half an hour to understand, that it still need an empty line below the title
(more accurate: in front of the code)

*Some Title*
--

    code that was below the title
*text explaining the code* 

I think in this case, the preview is very missleading, since I scrolled through it wondering where to find unformated code, while everything was displayed fine.

6
  • 3
    Right, so there is an issue with the preview not handling this case properly.
    – Martijn Pieters Mod
    Commented Feb 15, 2018 at 14:17
  • @MartijnPieters is there a better way to report such an issue? I thought meta would be something like the general platform to talk about stackoverflow and its features.?
    – Skandix
    Commented Feb 15, 2018 at 14:21
  • 6
    This is the right place.
    – Martijn Pieters Mod
    Commented Feb 15, 2018 at 14:23
  • 7
    You could update the question to make it explicit how the preview still shows the code block correctly.
    – Martijn Pieters Mod
    Commented Feb 15, 2018 at 14:29
  • 1
    @MartijnPieters: I gave it a try, but I'm not that confident with my language skills. Hope this is more satisfying now.
    – Skandix
    Commented Feb 15, 2018 at 14:42
  • I remember having this same bug when I was a beginner in StackOverflow. I thought I was doing something wrong. I left the code unformatted and someone else edited it afterwards. It's good to finally know the reason why :) (2 years later) Commented Feb 18, 2018 at 0:20

You must log in to answer this question.

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