Allan Odgaard wrote:
On Feb 5, 2005, at 20:46, Xavier Noria wrote:
Just for the record, there are some utilities out there that can help: GNU Source-highlight http://www.gnu.org/software/src-highlite/
Since the OP wanted line numbers, I also did a small awk script to insert these, only tested with C++ output though: expand -3 | source-highlight -scpp -fhtml \ | awk '
/^<pre><tt>/ { sub("<pre><tt>", "<pre><tt> 1: "); print $0; next; }
/^</tt></pre>/ { print $0; next; }
{ printf("%3d: %s\n", ++line + 1, $0); } '
I also just noticed that the piping through awk isn't necessary with source-highlight. Just add "-n" to the command and it will automatically output it with line numbers. Even better, if you add "--line-number-ref", it will number all output lines and generate an anchor that can be referred to from another document! That could come in VERY handy.
Chris