• Post Reply Bookmark Topic Watch Topic
  • New Topic

source code detection feature  RSS feed

 
Randall Kippen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone had the suggestion on this website about 2 years ago:

http://www.coderanch.com/t/2104/Ranch-Office/Source-Code-Detection

I also had the same idea. At my website:
http://www.graphbuilder.com/detect_code/
http://www.graphbuilder.com/detect_code/detect_code.html
You can download the source and see a demo.

This feature could be ported to JavaScript and be run after the add button is pressed, but before the form is submitted.

I did some informal testing. It seems pretty good, maybe 90% of the time it places the code tags in the correct location. There are some improvements that could be made, but the idea is simple.

The search begins at the bottom of the text. When a curly bracket is found, find the matching top curly bracket. From there, continue to search upwards. Include every line that begins with a Java keyword.

That's it.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without quite a bit of work, it would be hard to get that working in the JSP, HTML/Javascript, XML, ANT, and, scripting forums.

It may still be worth having for the others though.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not so sure. Unless it works for 99% of all cases, I suspect that it will only lead to posters (including me) becoming lazy and depending on that feature, leading to even more horribly formatted posts.

A simple reminder when code is found that isn't inside code tags might be better.
 
Randall Kippen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At least you are open to the idea. I think 99% is possible.
I think unless someone was explicitly trying to break the
code detection, that it could work 99.9%.

Code or posts that don't contain curly brackes would be 100%
unaffected. Thus, some small code segments (e.g. one liners)
would be missed. However, it's easy to read one liners and
they don't really need to have code tags.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Randall Kippen:
At least you are open to the idea. I think 99% is possible.
I think unless someone was explicitly trying to break the
code detection, that it could work 99.9%.

Code or posts that don't contain curly brackes would be 100%
unaffected. Thus, some small code segments (e.g. one liners)
would be missed. However, it's easy to read one liners and
they don't really need to have code tags.


The JSP, HTML/Javascript, XML, ANT, and, the Scripting Language forums comprise more than .1%.
 
Randall Kippen
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:


The JSP, HTML/Javascript, XML, ANT, and, the Scripting Language forums comprise more than .1%.


Yes, those forums would continue to require manual code tags until code detection routine had been provided. I guess it is too complicated or too hard for you do to. Forget I suggested it.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Randall Kippen:
Yes, those forums would continue to require manual code tags until code detection routine had been provided.


I guess that might work.

I guess it is too complicated or too hard for you do to. Forget I suggested it.


Ben couldn't do much about it, anyway - that would be the job of a bartender or sheriff.

But it might well be too complicated with our current forum software - as far as I know, it isn't easy to add new features to it.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66154
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess it is too complicated or too hard for you do to. Forget I suggested it.


Honey and vinegar, dude.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!