NAME
Highlight - a universal sourcecode to formatted text
converter
SYNOPSIS
highlight
[acdefhiklnopqrstuvwzABCDEHIKLOPRSTXVWZ] [-i input file] [-o output
file] [-S syntax] [-O outdir] [-B wildcard] [-H language] [-t num]
[-c style_outfile] [-e style_infile] [-s style] [-D data dir] [-E
add. data dir] [-F format] [-u encoding] [input files]
DESCRIPTION
Highlight converts sourcecode to HTML,
XHTML, RTF, LaTeX, TeX, XML or ANSI escape sequences. There are 40
colour themes available. Highlight recognizes keywords,
numbers, strings, comments, symbols and preprocessor directives. It
supports Action Script, ADA 95, Agda, AMPL, Aspect, Assembler,
Amtrix, Avenue, (G)AWK, Bash, BlitzBasic, BMS, C, C++, C#,
ClearBasic, Clipper, Cobol, CSS, DOS-Batch, Eiffel, Euphoria,
Express, Felix, Frink, Forth, Fortran, Haskell, HTML, HTTPD, IDL,
INI, IO, Jasmin, Java, JavaScript, JSP, LaTeX, LDIF, Lotus Script,
Lua, Make, Maya, Matlab, MaxScript, Modelica, Modula 3, Nasal,
Nice, Oberon, Object Script, OCaml, Pascal, Paradox, PATROL, Perl,
PHP, Pike, PL/1, PL/SQL, POV Ray, Progress, Python, Relax NG, Rexx,
Ruby, Small, SML, Spin, Sybase, Squirrel, SuperX++, VHDL, Visual
Basic, XML and more.
It's easily possible to enhance highlight's database of
programming languages and colour themes. See the README file for
details.
General options
- -B, --batch-recursive=<wildcard>
- convert all files matching the wildcard (uses recursive search)
- -D, --data-dir=<path>
- set path to highlight data directory
- -E, --add-data-dir=<path>
- set path to an additional data directory, which is searched
first
- -H, --help-lang=<lang>
- print help in given language <lng>=[br, cz, en, es, de,
fr]
- -h, --help
- print this help
- -i, --input=<file>
- name of input file
- -o, --output=<file>
- name of output file
- -O, --outdir=<output directory>
- name of output directory
- -P, --progress
- print progress bar in batch mode
- -S, --syntax=<type>
- define type of source code, necessary if input filename is
unknown
- -v, --verbose
- print debug info to stderr
- -p, --list-langs
- list installed language definitions
- -q, --quiet
- supress progress info in batch mode
- -w, --list-themes
- list installed themes
- --force
- generate output if language type is unknown
- --print-config
- print path configuration
- --version
- print version and copyright info
Output formats
- -A, --ansi
- generate terminal output (16 colours)
- -L, --latex
- generate LaTeX file
- -M, --xterm256
- generate terminal output (256 colours)
- -R, --rtf
- generate RTF file
- -T, --tex
- generate TeX file
- -X, --xhtml
- generate XHTML 1.1 file
- -Z, --xml
- generate XML file
Output formatting options
- -c, --style-outfile=<file>
- name of style definition file
- -d, --doc-title
- -d, --doc-title
- document title
- document title
- -e, --style-infile=<file>
- name of file to be included in style-outfile
- -f, --fragment
- omit header and footer of the output document
- -F, --reformat=<style>
- reformat output in given style. <style>=[ansi, gnu, kr,
java, linux]
- -I, --include-style
- include style definition in output
- -j, --line-number-width
- line number width incl. left padding
- -k, --font=<font>
- defines font (specific to output format)
- -K, --font-size=<num?>
- defines font size (specific to output format)
- -l, --linenumbers
- print line numbers in output file
- -m, --line-number-start=<cnt>
- start line numbering with cnt (assumes -l)
- -s, --style=<style name>
- define highlighting style which should be used
- -t --replace-tabs=<num>
- replace tabs by num spaces
- -u, --encoding=<enc>
- define output encoding which matches input file encoding; omit
encoding information if enc=NONE
- -V, --wrap-simple
- wrap long lines without indenting function parameters and
statements
- -W, --wrap
- wrap long lines (use with caution)
- -z, --zeroes
- fill leading space of line numbers with zeroes
(X)HTML OPTIONS
- -a, --anchors
- attach anchors to lineneumbers (HTML only)
- -C, --print-index
- print index file with links to output files
- --ordered-list
- print lines as ordered list items (assumes -l)
LaTeX OPTIONS
- -b, --babel
- disable Babel package shorthands
- -r, --replace-quotes
- replace double quotes by \dq (assumes -f is set)
RTF OPTIONS
- -x, --page-size
- define page size (a3, a4, a5, b4, b5, b6, letter)
If no in- or output files are specified, stdin and stdout will
be used for in- or output. -t will be ignored if -F is set. -i and
-o will be ignored if -b or -B is set. -c will be ignored if the
output format does not support referenced style files. HTML will be
generated, if no other output format is given Style definitions are
stored in highlight.css (HTML, XHTML) or highlight.sty (LaTeX, TeX)
if neither -c nor -I is given. Reformatting code will only work
with C, C++, C# and java input files.
BUGS
The converter is not able to recognize mixed code like
PHP and JavaScript in one file. RTF output will ignore background
colour information. The wrapping options will cause faulty
highlighting of long single line comments and directives.
FILES
The parsing information of the programming languages
is stored in /usr/share/highlight/langDefs/. You may enhance
highlight's parsing capabilities by adding more *.lang -
files to this directory. You can also define other directories with
-D, or add search paths with -E. Documentation files are stored in
/usr/share/doc/highlight/ , configuration files in
/etc/highlight/.
Examples
Single file conversion:
highlight -o hello.html -i hello.c
highlight -o hello.html hello.c
highlight -o hello.html -S c < hello.c
highlight -S c < hello.c > hello.html
Note that a file highlight.css is created in the current
directory.
Batch file processing:
highlight -X -B '*.cpp' -O /home/you/html_code/
converts all *.cpp files in the current directory and its
subdirectories to xhtml files, and stores the output in
/home/you/html_code.
highlight -L * -O /home/you/latex_code/
converts all files to LaTeX, stored in /home/you/latex_code/.
Use --quiet to improve performance of batch file processing
(recommended for usage in shell scripts).
Use highlight -A <yourfile> | less -R to display a source
file in a terminal.
AUTHORS
Andre Simon <andre.simon1@gmx.de>
SEE ALSO
README file and highlight webpage at http://www.andre-simon.de/ and
http://wiki.andre-simon.de.