# 適切にフォーマットされていないコードを投稿しているユーザーを捕まえ、教育する

**URL:** https://meta.discourse.org/t/catch-and-educate-users-posting-code-without-properly-formatting-it/67958
**Category:** Feature
**Created:** [2017 年 8 月 13 日午前 9:29 UTC](https://meta.discourse.org/t/catch-and-educate-users-posting-code-without-properly-formatting-it/67958 "2017-08-13T09:29:03Z")
**Posts on this page:** 10
**Page:** 2

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2019 年 3 月 21 日午前 4:36 UTC](https://meta.discourse.org/t/catch-and-educate-users-posting-code-without-properly-formatting-it/67958/21 "2019-03-21T04:36:12Z")

</div>

Yes sounds like a plan, if you are comfortable with this being client only then it can be done as a theme component which is awesome cause you will be able to reach lots more people.

> **[Theme Creator](https://discourse.theme-creator.io/)**
>
> Demonstration sandbox for Discourse

---

<div class="post-metadata">

### Author: ![lionel-rowe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lionel-rowe/32/134288_2.png) [@lionel-rowe](https://meta.discourse.org/u/lionel-rowe)
#### Post date: [2019 年 3 月 22 日午前 10:34 UTC](https://meta.discourse.org/t/catch-and-educate-users-posting-code-without-properly-formatting-it/67958/22 "2019-03-22T10:34:55Z")

</div>

Nice! Didn’t even know that feature existed. Looks like it could be perfect for this use case. The only caveat is that I can’t see any way to attach a new custom user field (`has_dismissed_code_notice`) without access to the back end. I guess there might be some hacky way of achieving the same effect? Alternatively, there’s always `localStorage`, but that doesn’t persist between devices.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2019 年 3 月 24 日午後 11:09 UTC](https://meta.discourse.org/t/catch-and-educate-users-posting-code-without-properly-formatting-it/67958/23 "2019-03-24T23:09:04Z")

</div>

Yeah theme user settings has been on our list for a while, we need it in quite a few spots now. We will get to it.

---

<div class="post-metadata">

### Author: ![lionel-rowe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lionel-rowe/32/134288_2.png) [@lionel-rowe](https://meta.discourse.org/u/lionel-rowe)
#### Post date: [2019 年 3 月 26 日午後 3:00 UTC](https://meta.discourse.org/t/catch-and-educate-users-posting-code-without-properly-formatting-it/67958/24 "2019-03-26T15:00:09Z")

</div>

Is that something you’d welcome pull requests for? If so, I’d be happy to give it a go. I’m assuming something like a remote version of `localStorage` would cut it (string-only key-value pairs). Values set and retrieved using a tuple of theme ID, user ID, and key. User ID must be current user if the field is set to private. Is there anything missing from that picture?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2019 年 3 月 26 日午後 6:24 UTC](https://meta.discourse.org/t/catch-and-educate-users-posting-code-without-properly-formatting-it/67958/25 "2019-03-26T18:24:49Z")

</div>

Sorry but a pr for this is not going to work, I started looking at this yesterday and getting this to work just right with minimal cost is very very fiddly, I am rather stickler about minimizing queries on first load, doing so here is hard mode ++

I do really want this change so I may plug at it a bit more over the next few days

---

<div class="post-metadata">

### Author: ![lionel-rowe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lionel-rowe/32/134288_2.png) [@lionel-rowe](https://meta.discourse.org/u/lionel-rowe)
#### Post date: [2019 年 3 月 28 日午前 4:29 UTC](https://meta.discourse.org/t/catch-and-educate-users-posting-code-without-properly-formatting-it/67958/26 "2019-03-28T04:29:10Z")

</div>

[Theme component topic is here.](https://meta.discourse.org/t/unformatted-code-detector-theme-component/112773)

---

<div class="post-metadata">

### Author: ![Jose\_C\_Gomez](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jose_c_gomez/32/137297_2.png) [@Jose\_C\_Gomez](https://meta.discourse.org/u/Jose_C_Gomez)
#### Post date: [2019 年 4 月 10 日午後 7:22 UTC](https://meta.discourse.org/t/catch-and-educate-users-posting-code-without-properly-formatting-it/67958/27 "2019-04-10T19:22:18Z")

</div>

So I just did this for my site mostly as a joke , but it works well and it is effective (thus far)  
It doesn’t automatically catch the offenders, but when I (or any of the leaders) see it we set a tag on the post of “formatcode”  
Then this happens the next time that user logs in

 ![Format](https://global.discourse-cdn.com/meta/original/3X/0/e/0ed24f5e9437dbc4468fa0d7939c21bf771b6526.gif)  
It sticks around until they correct the problem and remove the tag, so far we’ve throw it at a few people and the code ALWAYS gets cleaned up. It only shows up for the author of the post.

Anyways I thought it was fun, I haven’t made a plugin out of it (I don’t have the time) but its fairly straight forward javascript. If someone wants it let me know and I’ll post it

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2019 年 4 月 10 日午後 11:55 UTC](https://meta.discourse.org/t/catch-and-educate-users-posting-code-without-properly-formatting-it/67958/28 "2019-04-10T23:55:28Z")

</div>

OMG this is an epic thing you have done here 🤣

---

<div class="post-metadata">

### Author: ![Jose\_C\_Gomez](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jose_c_gomez/32/137297_2.png) [@Jose\_C\_Gomez](https://meta.discourse.org/u/Jose_C_Gomez)
#### Post date: [2019 年 4 月 11 日午後 1:44 UTC](https://meta.discourse.org/t/catch-and-educate-users-posting-code-without-properly-formatting-it/67958/29 "2019-04-11T13:44:59Z")

</div>

Here’s the code in case someone else wants to mess with it

> **[GitHub - josegomez/discourse-clippy-nag: For our own discourse site we implemented a...](https://github.com/josegomez/discourse-clippy-nag)**
>
> For our own discourse site we implemented a nagging clippy which reminds users to format their code. This is how we did it.

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [2025 年 2 月 21 日午後 10:25 UTC](https://meta.discourse.org/t/catch-and-educate-users-posting-code-without-properly-formatting-it/67958/30 "2025-02-21T22:25:25Z")

</div>

これには [Unformatted Code Detector](https://meta.discourse.org/t/unformatted-code-detector/112773?u=supermathie) があります

[Previous page](https://meta.discourse.org/t/catch-and-educate-users-posting-code-without-properly-formatting-it/67958.md?page=1)
