Converting colored output into html

The answer to this question is probably what you want.

It links to these tools, which do the conversion you're looking for:

  • Perl package HTML::FromANSI

  • aha, a C-language program (github repo)


Or just a shell script

https://github.com/pixelb/scripts/blob/master/scripts/ansi2html.sh

More details of this script http://pablomarin-garcia.blogspot.com/2011/04/converting-ansi-to-html-how-to-convert.html


You can try vim with AnsiEsc.vim plugin to view ANSI colors through escape codes, then redirect to standard output to vim - (make sure you've activated :syntax on). Then convert the file to HTML by vim command: :TOhtml. The generated HTML file should have coloured output.


To convert source code non-interactively into html, try the following command:

vim -E -s -c "let g:html_no_progress=1" -c "syntax on" -c "set ft=c" -c "runtime syntax/2html.vim" -cwqa myfile.c

Source: :help g:html_no_progress (part of :help TOhtml).

Note: You can use - instead of the myfile.c, to convert code from standard input.