Pages: [1]   Go Down
Author Topic: Auto-Detect the need for code tags?  (Read 968 times)
0 Members and 1 Guest are viewing this topic.
Austin, TX
Offline Offline
Faraday Member
**
Karma: 64
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Washington
Offline Offline
God Member
*****
Karma: 30
Posts: 780
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Offline Offline
Edison Member
*
Karma: 35
Posts: 1429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Where are the Nick Gammons of yesteryear?

Austin, TX
Offline Offline
Faraday Member
**
Karma: 64
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Offline Offline
Edison Member
*
Karma: 35
Posts: 1429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pete
Logged

Where are the Nick Gammons of yesteryear?

Washington
Offline Offline
God Member
*****
Karma: 30
Posts: 780
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pete
That didn't work right smiley-wink
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Offline Offline
Edison Member
*
Karma: 35
Posts: 1429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pete
(I previewed it this time!)
Logged

Where are the Nick Gammons of yesteryear?

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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? 

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.
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 64
Posts: 6055
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
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.

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.
Finally!  I could not figure out how you did it.  smiley-wink  Thank you!
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Pages: [1]   Go Up
Jump to: