Whenever I ask a user to show some code, or a more specific part of their code, they will very often paste it into a comment reply instead of appending it to their original question. This is especially true for new users where it may not be obvious that they can edit their original question.
There are libraries to facilitate classifying text from code. Whenever we detect an asker including code in a comment on their own question the UI would suggest that they append it to their original question instead.
Feasibility
There may be libraries built for this specific purpose that I wasn't able to find at first glance. Barring discovery of one, I see a few potential ways of doing this.
google/code-prettify has the ability to detect languages. Fork this code and repurpose it for this problem.
Roll your own simple code detector using some pattern matching as suggested here. Also, in addition to detecting code detect words with a dictionary lookup. Categorize terms as cody and non-cody. If "cody" terms cross some threshold then its probably code. This is obviously not a perfect solution and will result in a lot of false negatives for some languages, which I think is tolerable. There would also be a lot of false positives for those with troubled english, so english dictionary misses would need to be weighted lower than more obvious cody terms like brackets and semicolons.
Train a bayes classifier and host a code detection service (yikes).
Again, ideally we would find an existing library built for this specific purpose, and if it doesn't exist then it's definitely possible that the complexity ends up outweighing the benefit here :)
`