The discussion addresses how to prevent users from accidentally formatting posts as code blocks, often caused by a 4-space indent. outofthebox asks if it is possible to disable the ‘code’ format globally, as it is off-topic in their community and frequently occurs by mistake. dax suggests hiding the code button via CSS and changing the code formatting style setting from 4-spaces-indent to code-fences, noting that accidental indentation often stems from email clients or typing habits. omarfilip confirms that email apps, such as Thunderbird, often add these indents automatically. Falco and dax discuss the origins of this habit, linking it to traditional paper writing conventions or copy-pasting from word processors. Despite outofthebox implementing dax’s suggestions, they report that 4-space indents are still converted to code blocks. codinghorerror confirms there is no native option to disable this behavior globally. The thread concludes with outofthebox submitting a feature request, and roke_julian_lockhart noting that this is a common complaint across platforms, referencing similar issues on Reddit and GitHub regarding CommonMark standards.
How do they use a code by mistake? By clicking the code button in the editor? Or simply leaving 4 spaces at the beginning of the line?
You can try to hide the code button with CSS using:
.code.btn {
display: none;
}
You can also change the site setting code formatting style from the default 4-spaces-indent to code-fences. If users can leave 4 blanks spaces before a line (maybe because they use emails?) it is difficult for them to use ``` by mistake.
Those are great ideas - I’ve implemented both. Thank you!
I do think it is because they add four spaces to the start of a line. I wonder if this was a typing convention in some schools or something? Or it is entered via their email program? It seems to happen a couple of times a week.
I doubt they insert manually 4 space. I think instead that they write the posts via email. You should be able to determine this by looking at the post itself. If you see an envelope icon the post has been submitted by email.
Or they simple copy paste the text from an another program where they use the Tab to create new paragraphs,
You would be surprised! I had hundreds of users, in a instance where reply by email was disabled, putting the four spaces because they were mimicking pen and paper standards. They also did the same when using a word processor or email.
Dax, I’ve noted that even with this setting set as ‘code-fences’, the system still translates four spaces into a code formatting. Is there a way/option to disable the four spaces = code markdown/formatting globally on a site?
I ask because a couple of times a week a participant accidentally posts their comments in the code format, making it difficult to read. I think it is because this convention still prevails among some people:
Disable Code Formatting for inappropriate 4 space indent?
@outofthebox, you are not the first person to experience this problem. I’ve observed Reddit posts with hundreds of upvotes about how much some people despise this, and the CommonMark standards Discourse forum has a thread on it. I’ve summarised some of them online: