I noticed Ulix's book has nice syntax highlighting. After looking at the Makefile, it seems obvious the basic scheme is:
noweave tmp.nw > tmp.tex.in
./filter-uses.py < tmp.tex.in > tmp.tex
The syntax highlighting is being done in filter-uses.py
, which I've included for my own purposes.