Suggest users to use code block when pasting code snippet

We use discourse to run a user support forum about programming and related technical activities. New (or less technically savvy) users are not immediately familiar with this forum environment and naively paste code snippets (e.g. Python code) in a text box without appropriate code fences (e.g. triple backticks), which is often hard to read because the code indentation (and possibly some syntax constructs) are completely ruined.

Is there some approach/plugin to do something like:

  • detect that a user is pasting a code snippet without appropriate markers/fences (detection of source code could be configurable, based on commonly used languages or programming patterns for the forum)
  • and then show a simple popup/overlay/notificaion saying something along the lines of “Hey, it looks like you are pasting source code, make sure to put it a preformatted text block for optimal readability”, pointing to the button to do this

?

thanks in advance for any pointer

1 Like

Welcome to Meta :waving_hand:

Maybe this theme component is what you are looking for

5 Likes

Great, looks exactly like what I was hoping for
thanks for the quick answer!

4 Likes