GNU Source-highlight 3.1.7

by Lorenzo Bettini

This program, given a source file, produces a document with syntax highlighting. It also provides a C++ highlight library (new) (since version 3.0).

Source-highlight reads source language specifications dynamically, thus it can be easily extended (without recompiling the sources) for handling new languages. It also reads output format specifications dynamically, and thus it can be easily extended (without recompiling the sources) for handling new output formats. The syntax for these specifications is quite easy (take a look at the manual).

Source-highlight is a command line program, and it can also be used as a CGI.

Notice that source-highlight can also be used as a formatter (i.e., without highlighting): you can, for instance, format a txt file in HTML (and it will take care of translating special characters, such as, <, >, &).

Since version 2.2, source-highlight can also generate cross references; in order to do this it relies on GNU Ctags, http://ctags.sourceforge.net.

These are the output formats already supported:

These are the input languages (or input formats) already supported (in alphabetical order):

NOTICE: now the name of the program is source-highlight: there are no two separate programs, namely java2html and cpp2html, anymore.  However there are two shell scripts with the same name in order to facilitate the migration (however their use is not advised).

GNU Source-highlight is free software. Please see the file COPYING for details. For documentation, please read this file.

GNU Source-highlight is a GNU program and its main home page is at GNU site:
http://www.gnu.org/software/src-highlite

  1. GNU Source-highlight
    1. On-line Manual
    2. Download
      1. Anonymous Git Checkout
      2. Installation
    3. Changes in this release
    4. What you need to build source-highlight
    5. Usage and examples
    6. Style files
    7. Related Software and Links
    8. Credits
    9. Feedback
    10. TODO
    11. Mailing Lists

On-line Manual

This is the complete manual shipped with source-highlight. It details all the file formats used by source-highlight and also contains documentation on how to create your own language definitions.

If you want to use source-highlight library inside your C++ programs, you may want to read the manual of the library and the API documentation.

Download

You can download it from GNU's ftp site:
ftp://ftp.gnu.org/gnu/src-highlite/ or from one of its mirrors (see http://www.gnu.org/prep/ftp.html).

I do not distribute Windows binaries anymore; since, they can be built by using Cygnus C/C++ compiler, available at http://www.cygwin.com. However, if you don't feel like downloading such compiler or you experience problems with the Boost Regex library (please also keep in mind that if you don't have these libraries installed, and your C/C++ compiler distribution does not provide a prebuilt package, it might take some time, even hours, to build the Boost libraries from sources), you can request such binaries directly to me, by e-mail (find my e-mail at my home page) and I'll be happy to send them to you. An MS-Windows port of Source-highlight is available from http://gnuwin32.sourceforge.net; however, I don't maintain those binaries personally, and they might be out of date.

Language definition files and output language definition files, which are part of source-highlight distribution, can also be downloaded independently from, respectively:

However, note that the files you find at the above urls are tested with the latest version of source-highlight (thus, e.g., they may require features that are not present in an earlier version of source-highlight);

Anonymous Git Checkout

This project's git repository can be checked out through the following clone instruction:
git clone git://git.savannah.gnu.org/src-highlite.git

Further instructions can be found at the address:

http://savannah.gnu.org/projects/src-highlite.

And the git repository can also browsed on-line at http://git.savannah.gnu.org/cgit/src-highlite.git.

NOTE: Since version 3.1.2 of Source-highlight the CVS repository was dismissed in favor of Git (http://git-scm.com/).

Please notice that this way you will get the latest development sources of Source-highlight, which may also be unstable. This solution is the best if you intend to correct/extend this program: you should send me patches against the latest git repository sources.

If, on the contrary, you want to get the sources of a given release, through git, say, e.g., version X.Y.Z, you must specify the git tag rel_X_Y_Z.

When you compile the sources that you get from the git repository, before running the configure and make commands, you must run the command:

autoreconf -i

This will run the autotools commands in the correct order, and also copy possibly missing files. You should have installed recent versions of automake, autoconf and libtool in order for this to succeed.

We strongly suggest to use shadow builds, thus, create a build directory, say build and run configuration and make in that directory. To summarize, the steps to get the sources from git and make the first build are:

     git clone git://git.savannah.gnu.org/src-highlite.git
     cd src-highlite
     autoreconf -i
     mkdir build
     cd build
     ../configure
     make

Installation

Please, take a look at the Installation section of the manual. Since version 3.1.2, also a qmake based building mechanism is available, though discouraged.

Changes in this release

You can also find details about new features of source-highlight on my blog, in this area: http://tronprog.blogspot.com/search/label/source-highlight.

What you need to build source-highlight

Since version 2.0 Source-highlight relies on regular expressions as provided by boost (http://www.boost.org), so you need to install at least the regex library from boost.  Most GNU/Linux distributions provide this library already in a compiled form.

Usage and examples

Related Software and Links

Here we list some software related to source-highlight in the sense that it uses it as a backend (i.e., provides an interface to source-highlight) or it uses some of its features (e.g., definition files):

Credits

See CREDITS for detailed contributions and THANKS  for a complete list of people that helped me with Source-highlight :-)

Feedback

Please tell me if you like this software :-)

Actually I want to extend it, so if you have some ideas...
The most import one will be to make source-highlight more powerful :-)

Please send all bug reports by electronic mail to:
bug-source-highlight at gnu dot org

Or, even better, use

https://savannah.gnu.org/bugs/?group=src-highlite

TODO

Here's the list of TODO stuff, if you'd like to contribute :-)

Mailing Lists

The following mailing lists are available: if you want to subscribe to a mailing list just go to the URL and follow the instructions, or send me an e-mail and I'll subscribe you.

My home page is http://www.lorenzobettini.it

source-highlight is free software. See the file COPYING for copying conditions. Anyway I won't get offended if you send me a postcard :-)


Return to GNU's home page.

Please send FSF & GNU inquiries & questions to gnu@gnu.org. There are also other ways to contact the FSF.

Please send comments on these web pages to webmasters@gnu.org, send other questions to gnu@gnu.org.

Copyright (C) 2001 Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA

Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.

Updated:9 Jan 2001 mhw