禁用不恰当的 4 空格缩进代码格式?

Hi,

In my community, no one should ever post code. It would always be off-topic.

However, sometimes people do have their posts formatted as code by accident.

Is it possible to disable everyone from applying the ‘code’ format to content in their post?

2 个赞

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.

5 个赞

In my case it’s always the user’s email app adding an indent at the first line in a paragraph. Their posts by email are jumbled up as a result.

More here:

3 个赞

Hi @dax,

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.

That is/was the standard way to create a paragraph when writing on paper:

4 个赞

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,

3 个赞

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.

7 个赞

The Thunderbird email client does it automatically for some of my users. :unamused:

3 个赞

Dax,我注意到即使将此设置设为“代码围栏”,系统仍然会将四个空格转换为代码格式。有没有办法/选项可以全局禁用站点上的“四个空格=代码”Markdown/格式?

我问这个是因为每周都有几次,参与者不小心将评论以代码格式发布,导致难以阅读。我认为这是因为这种惯例在某些人中仍然盛行:

3 个赞

没有,没有任何方法可以做到这一点。

4 个赞

说得通!

请将此视为一个功能请求。

我想知道有多少比例的 Discourse 论坛需要代码块?在我看来,这似乎是社区中的少数派?

3 个赞