(fwiw, neither of the discobot tutorials cover fenced code blocks, or even mention code. They do teach how to insert a picture, which is another popular way to mis-post code. I couldn’t find anything to detect that.)
(@ChathuraGH your deleted post raised a valid concern.)
On devices that support touch input—including a lot of Windows laptops—Discourse’s editor toolbar makes it hard to find the Preformatted text button that inserts a code block:
The code button is hidden inside the gear menu.[1] (But Insert date/time is included in the main toolbar .)
Discourse decides toolbar contents based on presence of a touch input device, rather than responsive layout (it just wraps wide toolbars). On non-touch devices, Discourse includes the code button early in the editor toolbar, no need to dig around:
To fix this, we could customize Discourse’s CSS+JS (thread starting here) or add a theme component that shows the code button in all toolbar layouts.
(Also, it might be helpful to call this button “Code” rather than “Preformatted text.” I think that’s configured in Discourse under Admin > Customize > Text > js.composer.code_title.)
The gear/cog button has its own usability problems: a gear usually means “settings” or “preferences” (including elsewhere in Discourse itself!), not “more toolbar commands.” And nothing about it suggests it will pop up a menu. ↩︎
Thanks for reporting & investigating this. The Online Community WG is meeting today for the first time, I will make sure we get these changes made, but the appropriate people or get access to do so ourselves.
Nor I (trying to post private messages to myself).
Is there maybe an additional step to enable the theme component for everyone? Or maybe the “disable at trust level” or “sensitivity” settings need adjusting? (Does the default disable-at-trust-level disable it for all of us who have been here a while?)
I’m going to try a post directly from the unformatted-code-detector unit test cases next… [edit] and it definitely seems like it’s not enabled, at least for me.
If all else fails it would be really, really useful to have somewhere obvious that explains how to format code blocks.
Obviously, most people wouldn’t see it but it would make it much easier if I could find the explanation easily to link to it, rather than have to explain yet again how to do it (and work out how to show what I mean without the backticks themselves disappearing etc).
I have made the detector more strict now. Originally, I configured it to be enabled for all users, independently of their trust level, but I left the “sensitivity” (0.5) and “minimum post length” (50) unchanged. Today, I set sensitivity to 0.2 and minimum post length to 10.