Description

Code2HTML converts a program source code to syntax highlighted HTML. It may be called as a CGI script. It can also handle include commands in HTML files.

Have a look at the examples.

It currently supports the following languages: Ada, Awk, C, C++, HTML, Java, JavaScript, m4, Makefile, Pascal, Perl, SQL, ruby, povray, groff (very incomplete)

Status

As of 2012, code2html hasn't seen any development or action in over 10 years. It still works, but there probably are other syntax highlighters around that are faster and more versatile these days.

But then, if it works, why look for something else…

Download

ChangeLog

Latest version: 0.9.1 (January 2002)

tarball (gziped); PGP Signature; Keys
old/development versions.

Examples

ADA 95, Awk, C, C++, HTML, Java (example contributed by Adam VanderHook), Makefile, Pascal, Perl; HTML patching (you should look at its source too!).

Test it online

A deployment of the CGI version is right here.

HTML patching

HTML patching is a code2html feature that allows you to elegantly have embedded source code in an HTML file.

Assuming you have the following html file:

<!DOCTYPE HTML PUBLIC "-IETFDTD HTMLEN">
<html>
  <head>
    <title>Foobar</title>
  </head>

  <body>
    <h1>Foobar</h1>

    Hello everybody!

<!– code2html add -l c /home/weasel/foobar.c –>

    That's it.
  </body>
</html>

After running 'code2html -p thisfile.html' your file will look like this:

<!DOCTYPE HTML PUBLIC "-IETFDTD HTMLEN">
<html>
  <head>
    <title>Foobar</title>
  </head>

  <body>
    <h1>Foobar</h1>

    Hello everybody!

<!– code2html add -l c /home/weasel/foobar.c –>

< the syntax highlighted code of /home/weasel/foobar.c is here >

    That's it.
  </body>
</html>

For a world example see HTML patching (you should look at its source too!).

Manual

See the manpage.

Contrib

A few things have been contributed by other people and have not been integrated into the code2html release due to a variety of reasons such as time constraints.

Some of them can be found in contrib/.