Code fence warning

In order to reduce the number of posts made by newcomers with un-fenced code, is it possible to add some type of warning like:

  • a pinned thread about how to include code
  • scanning posts for keywords like def, print(, or import before posting, and suggesting to add code fences
  • A default post template that includes code fences and a snippet + explanation
  • ???

Sorry Terry, what’s “fenced code”?

Do you mean code that is indented by four spaces?

def func(arg):

or is there some other way I should be marking code?

Aside from that, I would support the idea of a pinned thread etc. Could
it also reference supplying a minimal working example?

Using three “`” characters to mark the beginning and end of code blocks. Comes from Markdown (or some extension of) I believe

def func(arg):

Is this (only/mostly) an issue on the “users” category (which I have muted)? I don’t see the same problem anywhere else…

It seems to me like it’s a subset of the general problem of “people don’t know how to / aren’t willing to take the time to format their messages properly” - possibly combined with a little bit of not knowing Markdown (although the toolbar should limit the impact of the latter).

I’m not sure about that… GitHub has a toolbar in the comment text box, yet we see issues filed without using code blocks all the time. I think most people neither know that’s a thing, nor care enough to ask when the format obviously looks wrong after submission.

In my experience, yes.

Is it possible to make custom bots? If so, maybe we could create a bot that sends a private message to a user if they post what looks like code without formatting it.