The solution is simple, add a -fcolor-diagnostics option and pipe the result to ansi2html. Of course since most of the interesting output is on stderr, don't forget to correctly redirect it (2>&1).
So in the end
$ clang -fcolor-diagnostics temp.c 2>&1 | ansi2html > temp.html
Many thanks to nemo for sharing this trick and several others on this blog!