Lately, I've seen lots of homework questions or of "first postings" for more professional help with really poor editing quality.
This is understandable and usually you can let it go and rework it yourself, or still make sense of the code. But some take it to a level of rudeness that's quite puzzling and would require lots of effort on the editors' part.
I was wondering if the following approach could be interesting:
When a question is posted, detect the first "language tag" (
c#... ) in the list. If one is found, assume this indentation for the code snippets.
This could be applied to the whole thread with decent results, but to be conservative maybe this could only apply to the question only, as it's very likely to be the intended effect. Alternatively, it could be done rather protectively and only done for the most active tags:
ruby, etc... and leave out esoteric languages.
While not perfect, this looks like a minimal effort thing for posters, and a good default behavior for a vast majority of cases.
I feel this must have come up in some form or another before, and I see some question suggestions that relate to this but not exact duplicates. Feel free to correct me and point me to them if you find them.
- Offering to indent with a checkbox (
we detecting you seem to use language "x", do you want us to indent that for youor proactively
we indented your code as it seemed to "x". Uncheck this if you don't want us to do that.).
- Offering a short-hand syntax like in many wikis and bug trackers to specify the language (a sort of pragma-thing, like
#lang java). That doesn't struck me as a great thing for questions as posters wouldn't be aware of that. However, it could be nice for answers.
And make sure that the backend actually rewrites the code, so it gets formatted nicely even in the saved question/answer source text.