Auto-Detect the need for code tags?

Since many new or first time posters come asking about code-related problems, it would be helpful to show them the code-tag feature. If a post contains the strings "void setup()" and "void loop()" but not any code tags, would it be possible to display a warning before committing the post? Maybe something similar to the red-message when someone replies while drafting a 2nd reply.

I would think code would be somewhat hard to detect programmatically but it is certainly possible.
Those functions as well as { } or more then a certain amount of ; could also work since those are all relatively rare in normal text.

It also might help if an icon could be designed which looks more like code. To me, the # symbol doesn't mean "code" at all whereas the icon for quoting text does imply quoting something. First time users might be more likely to use it if was more representative of what it does.

Pete

el_supremo:
To me, the # symbol doesn't mean "code" at all whereas the icon for quoting text does imply quoting something.

Maybe a big button that just says: "Code Tags" would work?

That's a good idea :slight_smile: Or perhaps the icon could just have "

"

Pete

el_supremo:
That's a good idea :slight_smile: Or perhaps the icon could just have "

"

Pete

That didn't work right :wink:

Oh Geez! :slight_smile:
What I meant to say was: Or perhaps the icon could just have "[ code ]"

Pete
(I previewed it this time!)

A lot of people don't actually post code that compiles or have them in it. You could have a "does this look like C?" algorithm. Similar to what Google Translate uses to auto-detect languages.

And I agree about the [code] button. (Special trick to make that appear). I made the (empty) gap after the "[" but before the word "code" to be in bold.

[quote author=Nick Gammon link=topic=102394.msg772299#msg772299 date=1335329170]
A lot of people don't actually post code that compiles or have them in it. You could have a "does this look like C?" algorithm. Similar to what Google Translate uses to auto-detect languages.[/quote]
I wasn't suggesting a "catch-all" type of approach. Just a simple "does the string: 'void setup()' exist and '[code]' does not"? If true, print a simple message and then allow the next post to go through. Again, similar to what happens when someone posts while you edit/create a post.

Finally! I could not figure out how you did it. :wink: Thank you!