Scroll to navigation

highlight(1) user documentation highlight(1)

NAME

Highlight - a universal sourcecode to formatted text converter

SYNOPSIS

highlight [OPTIONS]... [FILES]...

DESCRIPTION

Highlight converts sourcecode to HTML, XHTML, RTF, ODT, LaTeX, TeX, BBCode, SVG, XTERM or ANSI escape sequences. There are several colour themes available. Highlight recognizes keywords, numbers, strings, comments, symbols and preprocessor directives. It supports about 160 programming languages, which are defined in Lua scripts.

It's easily possible to enhance highlight's database of programming languages and colour themes. See the README file for details.

General options

convert all files matching the wildcard (uses recursive search)
set path to highlight data directory
set path to an additional configuration directory
set path to a lang or theme file
print this help
name of input file
name of output file
name of output directory
print progress bar in batch mode
set type of source code, necessary if input file suffix is missing
print debug info to stderr
list installed language definitions
supress progress info in batch mode
list installed themes
generate output if input syntax is unknown
execute Lua plug-in script; repeat option to apply multiple plug-ins
set input file for a plug-in (e.g. 'tags')
print path configuration
print stylesheet only (see --style-outfile)
ignore listed unknown file types (Example: --skip='bak;c~;h~')
define nested language which starts input without opening delimiter
test if input is a valid text file
print version and copyright info

Output formatting options

output file in given format <format>=[html, xhtml, latex, tex, rtf, odt, ansi, xterm256, bbcode, svg]
name of style definition file or output to stdout, if "stdout" is given as file argument
document title
name of file to be included in style-outfile
omit header and footer of the output document
reformat output in given style. <style>=[allman, banner, gnu, java, kr, linux, stroustrup, whitesmith]
include style definition in output
line length before wrapping (see -W, -V)
line number length incl. left padding
set font (specific to output format)
set font size (specific to output format)
print line numbers in output file
start line numbering with cnt (assumes -l)
set highlighting style (see --list-themes)
replace tabs by num spaces
set output encoding which matches input file encoding; omit encoding information if set to "NONE"
wrap long lines without indenting function parameters and statements
wrap long lines (use with caution)
fill leading space of line numbers with zeroes
output all keywords in given case if language is not case sensitive
set CR as end-of-line delimiter (MacOS 9)
omit trailing newline
omit line numbers of wrapped lines (assumes -l)

(X)HTML OPTIONS

attach anchors to line numbers (HTML only)
set anchor name prefix
use input file name as anchor name
print index file with links to all output files
print lines as ordered list items
set CSS class name prefix; omit class name if set to "NONE"
output CSS within each tag (verbose output)
enclose fragmented output with pre tag (assumes -f)

LaTeX OPTIONS

disable Babel package shorthands
replace double quotes by \dq
improve appearance of brackets and other symbols

RTF OPTIONS

set page size, <size>=[a3, a4, a5, b4, b5, b6, letter]
include character stylesheets

SVG OPTIONS

set image height (units allowed)
set image size (see --height)

GNU SOURCE-HIGHLIGHT COMPATIBILITY OPTIONS

create stand alone document
cancel the --doc option
the external style sheet filename
source language
specify tab length
number all output lines, optional padding
number all output lines and generate an anchor, made of the specified prefix
p + the line number (default='line')

output directory
if no language definition is found for the input, it is simply copied to the output

If no in- or output files are specified, stdin and stdout will be used for in- or output. HTML will be generated unless an other output format is given. Style definitions are stored in highlight.css (HTML, XHTML, SVG) or highlight.sty (LaTeX, TeX) if neither -c nor -I is given. Reformatting code (-F) will only work with C, C++, C# and Java input files.

BUGS

The wrapping options might cause faulty highlighting of multi line comments.

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 --data-dir. 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 --out-format=xhtml -B '*.cpp' -d /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 --out-format=latex * -d /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 --out-format=xterm256 <yourfile> | less -R to display a source file in a terminal.

AUTHORS

Andre Simon <as@andre-simon.de>

SEE ALSO

README file and highlight webpage at http://www.andre-simon.de/.

2012-10-03 Andre Simon