Discourse is still problematic for code

The old problem remains:

Please, please find a way to hack in some instruction about Markdown formatting. If Discourse itself can't do anything about it, maybe a sticky thread?

I believe we already have a pinned thread:

I never see it at the top of URLO myself, so I just assumed pinning only highlights it for users that are "new" in some sense.

As far as I understand it should be pinned for new users until they click it. Then it behaves like an unpinned thread. You should be able to see it pinned by logging out or opening the forum in a private window.

Though maybe the title should be changed to be a little more enticing to new users? When I wrote it I didn't know it would be pinned.

That looks good!

So sadly, it's not 100% effective. I'm not sure what more could be done :confused:

IMHO, the only thing more effective might be to modify the UI for writing posts. Add a "Code" button that inserts the backticks. Better yet make it replace the "Preformatted text" button. The same icon can be used then.

However I don't know if this is possible. Discourse hosting doesn't appear to be very customizable.

1 Like

My dream feature would be for Discourse to listen for "paste" events, check whether the pasted content appears to be code (based on some heuristics), and automatically insert the preformat markup when appropriate.

(Just making all pasted content preformatted by default might be a step forward. Pasting code is extremely common in our forums, and it would be easier for new users to remove the markup when it's not wanted than to figure out how to insert it when it is.)

4 Likes

At the very least, it would be nice if Discourse had a handful of string patterns that, if matched, cause it to show a reminder about wrapping code in triple backquotes.

5 Likes

There's a plugin for that: https://github.com/lionel-rowe/unformatted_code_detector but it looks like it has some issues and we might have to use a fork: https://github.com/lionel-rowe/unformatted_code_detector/issues/16#issuecomment-619383262

I found this by searching on Discourse's Discourse for "code formatting" and found a number of relevant posts:

6 Likes