I am working on my paper which needs a piece of XML to syntax highlighted. I’ve found Sublime with “Copy as RTF” plugins is useful, but as a programmer I prefer something that being done via commend line, and more importantly being easily customizable.
So I did a some searches and came across highlight. To install it on Ubuntu is quite simple
sudo apt-get install highlight
Then I can use highlight to convert the XML file to RTF and copy it to the paper I am working on.
Highlight has styles (samples can be found at http://www.andre-simon.de/doku/highlight/en/theme-samples.php
Highlight knows the syntax highlighting for a lot of languages including XML, C, Java, etc. http://www.andre-simon.de/doku/highlight/en/langs.php. I can use the file extension to choose the type of source code like “.xml” for XML. Alternatively, I can use option
-S. For output file format, currently it supports HTML, Latex, Tex, RTF, ANSI, SVG, etc, good enough for my task.
For example, I can get my XML file highlighted with this:
highlight -s zellner -O rtf foo.xml -o foo.rtf
This will use Courier New as the font, and depending on the theme/style used, some of the highlighting may be bold or italic. This is easy enough to change in Word or other word processing editor though.