OpenWrt Forum: Testing Unformatted Code Detector

FYI - We are currently testing a new component of the discourse forum software:

What does it do?

Users posting unformatted code will see a warning message instructing them how to format it correctly.

Feedback welcome

Your feedback, positive or negative, is very welcome!

Should you experience any issues, (e.g. false positives, like warning message is shown despite no code at all contained in the post), please let us know in this topic.
If possible, please provide the text that caused the issue so we can reproduce it and possibly report upstream.

Thanks! :slight_smile:


just got prompted when I edited to add the braces to upload... tad sensitive maybe

but it has post anyway... and dont ask again... so a small nitpick

maybe if i'd used proper grammar an put a space after flash it may not have... will test that later... kinda does look like code without the space...

yes... with space after flash it's ok... my bad... in this case... I think the logic is fine... and it's my grammar that was the issue...

1 Like

I assume footnotes trigger the code block detection as well, as I've been prompted about it while posting,

Do you see this as a big problem that should be looked into?


release[0] -> detected as code
release [0] -> not detected as code

Would it be an acceptable workaround for you to enter a space before the [0]?

I only saw false positives so far, but I consider this to be a great idea nevertheless, as it will help newcomers to realise that code formatting is actually an option. Now, if the false positives show up too often, some regulars will be annoyed (me included), but let's see whether this triggers too often before trying to fix it?

Please post the false positives here and we will see if we can improve the detection.


I'm just reporting the false positive(s) as I notice them, no complaints from me (not using code blocks where they should be is indeed much worse for every reader, than clicking away the nag screen).

(just for reference, I'm getting nagged about this post as well)

1 Like

Will do, but I clicked the last away and forgot which thread it was in....

It's great in general, but seems to miss shebang detection.
Perhaps someone can point this to the devs if they have a account.


Another false positive is, after editing the post with last two lines including/ following "-- ".

ok... so clicking ignore seems to nullify the message forever-more...

was not sure if it was message based or for all...

guess this is probably desirable behavior (i.e. once a user knows these things the messages would be/are more annoying than helpful)

I like the feature as it will decrease unformatted stuff from beginners.

Still, some funny false positives like a singular 44:1 (plus two words inside () ) in my short message here.

Would it be possible to somehow decrease sensitivity? What are the config options that you could tweak?

Edit: funny, posting it here did not trigger the warning. Maybe I mis-guessed the triggering thing.

The code detection triggers on at least half of my (non-code) posts (presumably due to bracket usage, not just footnotes), so it can be a bit annoying as well. Still the net-effect for new users is probably worth it.

1 Like

Seems it's not clear how to tweak the detection (in this case for adding keywords to be detected, but I guess sensitivity falls in the same range):

Seems that detection is triggered by "download:upload", i.e. the colon between two words. I have noticed that already with Network and Wireless Configuration

1 Like

Looks like underlying rules are here.

Sensitivity "code energy" settings seem to be in the files in the same dir.

Based on that a single curly bracket [ is enough to cause high value,

almost always seen only in code and never in regular text, such as [


It might be useful to add detection for shebang like @vgaetera suggested, plus add OpenWrt specific things like uci config file detection "^config " (although the UCI file might be detected in any case due to use of ' )

1 Like

See the topic I have linked above (where I'm also asking for root@ to be detected).

Yep, would be great if we could add some OpenWrt specific cases.

If someone feels proficient enough (certainly not me :slight_smile: ), feel free to provide a matching regex that we can test.

Some words from me as an admin: I think this Code Detector component is the best invention since sliced bread! :slight_smile:

Many users, even brand new ones, are applying the correct code formatting, without the need for admins to take corrective actions.
The number of posts where I need to add correct code formatting has gone down significantly, leaving me more time to do other stuff. That's great! :slight_smile:

It is certainly not perfect (yet), but given the complex task to detect different kinds of code within normal text I feel it does the job pretty good.


Not sure if it needs to be anything more complicated than these added to the non-html section... nonHtmlIndicators

"^config "

I marked all of those to be at the start of the line, as having root@ in the text might be viable. When that is in the beginning of the line, it is almost certainly commands grabbed from console. And not sure about escaping shebang chars :frowning: )

1 Like

agree... and once someone gets the hang of it... clicking ignore once... forever removes the pesky warnings and/or false detections... so in the big picture... it's mostly fine...