.TH code2html 1 "" Mar-2000 "" .\" manual page by Peter Palfrader .\" using pages made by Jukka A. Ukkonen and pod as references .\" This manual page is under the same license as code2html itself. See below. .SH NAME .LP code2html \- Converts a program source code to HTML .SH SYNOPSIS .LP (1) \fBcode2html\fP [\fIoptions\fP] [\fIinput-file\fP [\fIoutput-file\fP]] .LP (2) \fBcode2html\fP \fB\-p\fP [\fIfile\fP [\fIalternate-outfile\fP]] .LP (3) \fBcode2html\fP (as a CGI script; see the section on \fICGI\fR) .SH DESCRIPTION .LP \fBcode2html\fR is a perl script which converts a program source code to syntax highlighted HTML, or any other format for wich rules are defined. .SS (1) OPTIONS .IP "\fIinput-file\fP" 8 Is the file which contains the program source code to be formatted. If not specified or a minus (\-) is given, the code will be read from STDIN. .IP "\fIoutput-file\fP" 8 Is the file to write the formatted code to. If not specified or a minus (\-) is given, the code will be written to STDOUT. .IP "\fB\-l\fP, \fB--language-mode\fP" 8 Specify the set of regular expressions to use. These have to be defined in a language file (see \fBFILES\fR below). To find out which language modes are defined, issue a \fBcode2html --modes\fR. .IP This input is treated case-insensitive. .IP If not given, some heuristics will be used to determine the file language. .IP "\fB\-v\fP, \fB--verbose\fP" 8 Prints progress information to STDERR. .IP "\fB\-n\fP, \fB--linenumbers\fP" 8 Print out the source code with line numbers. .IP "\fB\-N\fR, \fB--linknumbers\fP" 8 Print out the source code with line numbers. The linenumbers will link to themselves, which makes it easy to send links to lines. .IP "\fB\-P\fR, \fB--prefix\fP" 8 Optional prefix to use for line number anchors. .IP "\fB\-t\fP, \fB--replace-tabs\fP[=\fITABSTOP-WIDTH\fP]" 8 Replace each occurence of a \fC\fP character with the right amount of spaces to get to the next tabstop. Default is a tabstop width of 8 characters. .IP "\fB\-L\fP, \fB--language-file\fP=\fILANGUAGE-FILE\fP" 8 Specify an alternate file to take the language and output-format definitions from (see the section on \fBFILES\fP below). .IP "\fB\-m\fP, \fB--modes\fP" 8 Print all language modes and output-formats currently defined to STDOUT and exit succesfully. Also prints modes from a \fILANGUAGE-FILE\fP given by \fB--language-file\fP if applicable. .IP "\fB--fallback\fP=\fILANG\fP" 8 If the language mode given with \fB--language-mode\fP cannot be found then use this mode. .IP \fB--fallback plain\fP for instance is usefull when \fBcode2html\fP is called from a script to ensure output is created. .IP "\fB\-h\fP, \fB--help\fP" 8 Print a short help and exit succesfully. .IP "\fB\-V\fP, \fB--version\fP" 8 Print the program version and exit succesfully. .IP "\fB\-c\fP, \fB--content-type\fP" 8 Prints \fC\*(rqContent\-Type: text/html\\n\\n\*(lq\fP (or whatever the output-format defines as a content-type) prior to the rest of the output. Usefull if the script is ivoked as a cgi script. .IP "\fB\-o\fP, \fB--output-format\fP" 8 Selects the output-format. html is the default. To find out which outputformats are defined, issue a \fBcode2html --modes\fP. .IP "\fB\-H\fP, \fB--no-header\fP" 8 do not make use of the template defined by the output-format. For HTML this means that there will be no \fC\fP, \fC\fP, and no \fC\fP tags. .IP "\fB--template\fP=\fIFILE\fP" 8 overrides the default template for the given output format. If \fB--no-header\fP is given too, this has no meaning, since the template is ignored anyway. .IP "\fB\-T\fP, \fB--title\fP" 8 Set the title of the produced output file. Only works if the template does support setting the title. .IP "\fB\-w\fP, \fB--linewidth\fP=\fILINEWIDTH\fP" 8 Wrap lines after \fILINEWIDTH\fP characters. Default is to not wrap lines at all. .IP "\fB\-b\fP, \fB--linebreakprefix\fP=\fILINEPREFIX\fP" 8 Use \fIfILINEPREFIX\fP at the start of wrapped lines. Default is "\[Fc] ". .SS (2) HTML patching .LP \fBcode2html\fP \fB\-p\fP [\fIfile\fP [\fIalternate-outfile\fP]] .LP \fBcode2html\fP also allows you to have inline source code in an html file. It can then take this html file and insert the syntax highlighted code. .LP If no file is given, \fBcode2html\fP reads from STDIN and writes to STDOUT. If just one file is given it replaces this file with the output. If two files are provided, the first one is read from and the second one written to. .LP To use this feature, just insert a like like this into your html file: .IP \fC \-\->\fP .LP the syntax highlighted file will be inserted at this position enclosed in \fC
\fP tags.

.LP
All options that can be given on the command line like
\fB--linenumbers\fP etc. work.
\fB--help\fP, \fB--version\fP, etc. work too however it is not very
intelligent to use them :).
Using \fB--output-format\fP to choose a non-HTML
outputformat is not adviseable.
\fB--content-type\fP is ignored.

.LP
You may also write the program's source code directly in
the html file with the following syntax:

.IP
\fC
.sp
\-\->

.LP
It is usually a good idea to at least give
the \fB--language-mode\fP option to specify the language.

.SS
(3) CGI
.LP
If the the script is used as a CGI script
(\fBGATEWAY_INTERFACE\fP environment set and no command line arguments given)
\fBcode2html\fP reads the arguments either from the query string or
from SDTIN.
(methods POST and GET).

.LP
\fB--content-type\fP is switched on automatically and
the output always goes to STDOUT.

.LP
The following parameters/options are accepted:

.IP "\fBlanguage-mode\fP \- optional" 8
`c', `cc', `pas', etc.

.IP
if not given, some heuristics are used to find out the language.

.IP "\fBfallback\fP \- optional" 8
`plain', `c', etc. if language-mode cannot be found, use this one

.IP "\fBinput-selector\fP \- optional" 8
either `file', `cgi-input1', `cgi-input2', or `REDIRECT_URL'
.IP
default: file

.IP "\fBfilename\fP" 8
file to read from if \fBinput-selector\fP is `file'

.IP "\fBcgi-input1\fP" 8
The source code to syntax highlight.
For example from a \fC