Unformatted Code Detector theme component

theme-component
(Lionel Rowe) #1

Links

Usage

After installation, users posting unformatted code will see a warning message instructing them how to format it correctly.

Sensitivity and whether it detects HTML are configurable via theme settings.

Issues

  • “Do not show this message again” only works per device, not per user. This is a known issue and will be fixed once Discourse gains the functionality to attach user info from themes.
23 Likes
Catch and educate users posting code without properly formatting it
#2

I do like this, but the mesage seems a bit too much IN YOUR FACE!!!

1 Like
(Stephen) #3

As the purpose is to interrupt the posting flow and force the user to make a choice, isn’t that the point?

3 Likes
(Lionel Rowe) #4

The message text is configurable through localization settings, but do you mean the message itself or the way it’s displayed? I’d certainly be open to suggestions on how to improve the user experience. @Stephen is right though — interrupting the flow is intentional. The challenge is to do so in a way that quickly informs the user without overwhelming them.

7 Likes
(Chaboi 3000) #5

This is quite essential to our forum due to the fact that many new users ignore our topic about code formatting and most of our topics are about assistance in code. It makes our life much easier by informing them of informatted code. Thanks @lionel-rowe

8 Likes
(Lionel Rowe) #8

v0.5 is now out. I’m gonna start documenting changes properly on this topic. I expect most updates from now will be dealing with edge cases.

Changelogs

v0.5

Fix false positive on URLs containing snake case (e.g. https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Client-side_storage)

v0.6

Fix two more types of URL-related false positives:

  • Parens in path (e.g. https://en.wikipedia.org/wiki/LAN_(disambiguation))
  • Array query params (e.g. https://www.example.com?foo[0]=bar&foo[1]=baz)

v0.7

Ignore strings like “O(n)”.

v0.8

  • Ignore emojis (e.g. :slightly_smiling_face: => :slightly_smiling_face:).
  • Ignore special characters for copyright/TM/registered (e.g. Trademarked(TM) => Trademarked™).
  • Ignore anything formatted like a URL.
6 Likes