All that's needed for this is to detect the ANSI escape codes and map them to HTML, e.g. "<span class="ansi-red">...</span>" or something like that.