The most favorite feature of StackOverflow for me is that it can automatically detect code in post and set appropriate color to the code.
I’m wondering how the color is set. When I do a Ctrl+F5 on a page, the code seems first be black text, then change to be colorful. Is it done by jQuery?
In reply to..
It doesn’t. The highlighter is very dumb, but manages to gets away with it because most programming languages are so similar. Nearly everything uses syntax close-enough to..
..that most stuff highlights properly. The above isn’t an actuall programming language, but it highlights perfectly.
There are exceptions, for example, it can sometimes treat a
/as the start of a regex (as in Perl/Ruby). when it is not:..but these are fairly rare, and it does a good job of working out most stuff, like..