I’m looking for an open source, cross platform (Windows & Linux at least) command line tool to take some code (C++, but multiple languages would be sweet), and spit out valid a XHTML representation of that code, with syntax highlighting included.
Ideally the XHTML should just wrap the code with <span> and <div> tags with different classes so I can supply the CSS code and change the colouration, but that’s an optional extra.
Does anyone know of such an application?
I can recommend Pygments. It’s easy to work with and supports a lot of languages. It does what you want, i.e., it wraps the code in
<span>tags:gives
and you can then use one of the supplied style sheets of make your own.
You can also call it via it’s
pygmentizescript. The script can format the output in different ways: HTML, LaTeX, ANSI color terminal output.