1highlight(1)                  user documentation                  highlight(1)
2
3
4

NAME

6       Highlight - a universal sourcecode to formatted text converter
7
8

SYNOPSIS

10       highlight [OPTIONS]... [FILES]...
11
12

DESCRIPTION

14       Highlight converts sourcecode to HTML, XHTML, RTF, ODT, LaTeX, TeX, BB‐
15       Code, Pango markup, SVG, XTERM or ANSI  escape  sequences.   There  are
16       several  colour  themes available.  Highlight recognizes keywords, num‐
17       bers, strings, comments, symbols and preprocessor directives.  It  sup‐
18       ports  about  180  programming  languages,  which  are  defined  in Lua
19       scripts.
20
21
22       It's easily possible to enhance  highlight's  database  of  programming
23       languages and colour themes.  See the README file for details.
24

GENERAL OPTIONS

26       -B, --batch-recursive=<wildcard>
27              convert all files matching the wildcard (uses recursive search)
28
29       -D, --data-dir=<path>
30              set path to highlight data directory
31
32       --config-file=<file>
33              set path to a lang or theme file
34
35       -h, --help[=topic]
36              print this help or a topic description <topic> = [syntax, theme,
37              plugin, config]
38
39       -i, --input=<file>
40              name of input file
41
42       -o, --output=<file>
43              name of output file
44
45       -d, --outdir=<output directory>
46              name of output directory
47
48       -P, --progress
49              print progress bar in batch mode
50
51       -S, --syntax=<type|path>
52              set type of source code, necessary if input file suffix is miss‐
53              ing.  The  syntax  may  also  be defined as path of the language
54              file.
55
56       --syntax-by-name=<name>
57              specify type of source code by given name.  Will not read a file
58              of  this  name,  useful for stdin and to determine the syntax of
59              the file before piping its content  to  highlight.  This  option
60              overrides --syntax.
61
62       --syntax-supported
63              test  if  the  given  syntax  can be loaded and print the result
64              (assumes -S or --syntax-by-name)
65
66       -v, --verbose
67              print debug info to stderr; repeat to show more information
68
69       -q, --quiet
70              suppress progress info in batch mode
71
72       --force[=syntax]
73              generate output if input syntax is unknown. The fallback  syntax
74              may be set here, Plain Text is default.
75
76       --list-scripts=<type>
77              list installed scripts <type> = [langs, themes, plugins]
78
79       --list-cat=<categories>
80              filter  the  scripts  by  the given categories (example: --list-
81              cat='source;script')
82
83       --max-size=<size>
84              set maximum input file size (examples: 512M, 1G; default: 256M)
85
86       --plug-in=<script>
87              execute Lua plug-in script;  repeat  option  to  apply  multiple
88              plug-ins
89
90       --plug-in-param
91              set  plug-in  input  parameter. This might be an input file name
92              (ie. 'tags').
93
94       --print-config
95              print path configuration
96
97       --print-style
98              print stylesheet only (see --style-outfile)
99
100       --skip=<list>
101              ignore listed unknown file types (example: --skip='bak;c~;h~')
102
103       --stdout
104              output to stdout (batch mode, --print-style)
105
106       --validate-input
107              test if input is a valid text file
108
109       --version
110              print version and copyright info
111
112

OUTPUT FORMATTING OPTIONS

114       -O, --out-format=<format>
115              output file in given format <format>=[html, xhtml,  latex,  tex,
116              rtf, odt, ansi, xterm256, truecolor, bbcode, pango, svg]
117
118       -c, --style-outfile=<file>
119              name of style definition file
120
121       -T, --doc-title
122              document title
123
124       -e, --style-infile=<file>
125              name of file to be included in style-outfile
126
127       -f, --fragment
128              omit header and footer of the output document (see --keep-injec‐
129              tions)
130
131       -F, --reformat=<style>
132              reformat output in given style.  <style>=[allman,  gnu,  google,
133              horstmann,  java,  kr,  linux,  lisp,  mozilla, otbs, pico, vtk,
134              ratliff, stroustrup, webkit, whitesmith]
135
136       -I, --include-style
137              include style definition in output
138
139       -J, --line-length=<num>
140              line length before wrapping (see -V, -W)
141
142       -j, --line-number-length=<num>
143              line number length incl. left padding. Default length: 5
144
145       -k, --font=<font>
146              set font (specific to output format)
147
148       -K, --font-size=<num?>
149              set font size (specific to output format)
150
151       -l, --line-numbers
152              print line numbers in output file
153
154       -m, --line-number-start=<cnt>
155              start line numbering with cnt (assumes -l)
156
157       --line-range=<start-end>
158              output only lines from number <start> to <end>
159
160       -s, --style=<style name|path>
161              set highlighting style (theme). Add 'base16/' prefix  to  use  a
162              Base16 theme. The theme may also be defined as path of the theme
163              file.
164
165       -t  --replace-tabs=<num>
166              replace tabs by num spaces
167
168       -u, --encoding=<enc>
169              set output encoding which matches input file encoding; omit  en‐
170              coding information if set to "NONE"
171
172       -V, --wrap-simple
173              wrap lines after 80 (default) characters without indenting func‐
174              tion parameters and statements.
175
176       -W, --wrap
177              wrap lines after 80 (default) characters (use with caution).
178
179       -z, --zeroes
180              fill leading space of line numbers with zeroes
181
182       --isolate
183              output each syntax token in separate tags (verbose output)
184
185       --keep-injections
186              output plug-in header and footer injections in spite of -f
187
188       --kw-case=<upper|lower|capitalize>
189              output all keywords in given case if language is not case sensi‐
190              tive
191
192       --no-trailing-nl[=mode]
193              omit  trailing  newline.  If mode is "empty-file", omit only for
194              empty input
195
196       --no-version-info
197              omit version info comment
198
199       --wrap-no-numbers
200              omit line numbers of wrapped lines (assumes -l)
201
202

(X)HTML OPTIONS

204       -a, --anchors
205              attach anchors to line numbers (HTML only)
206
207       -y, --anchor-prefix=<str>
208              set anchor name prefix
209
210       -N, --anchor-filename
211              use input file name as anchor name
212
213       -C, --print-index
214              print index file with links to all output files
215
216       -n, --ordered-list
217              print lines as ordered list items
218
219       --class-name=<str>
220              set CSS class name prefix; omit class name if set to "NONE"
221
222       --inline-css
223              output CSS within each tag (verbose output)
224
225       --enclose-pre
226              enclose fragmented output with pre tag (assumes -f)
227
228

LATEX OPTIONS

230       -b, --babel
231              disable Babel package shorthands
232
233       -r, --replace-quotes
234              replace double quotes by \dq
235
236       --beamer
237              adapt output for the Beamer package
238
239       --pretty-symbols
240              improve appearance of brackets and other symbols
241
242

RTF OPTIONS

244       --page-color
245              include page color attributes
246
247       -x, --page-size=<size>
248              set page size, <size>=[a3, a4, a5, b4, b5, b6, letter]
249
250       --char-styles
251              include character stylesheets
252
253

SVG OPTIONS

255       --height=<h>
256              set image height (units allowed)
257
258       --width=<w>
259              set image size (see --height)
260
261

TERMINAL ESCAPE OUTPUT OPTIONS (XTERM256 OR TRUECOLOR)

263       --canvas[=width]
264              set background colour padding (default: 80)
265
266

LANGUAGE SERVER OPTIONS

268       --ls-profile=<server>
269              load LSP configuration from lsp.conf
270
271       --ls-delay=<ms>
272              set server initialization delay in milliseconds
273
274       --ls-exec=<bin>
275              set server executable name
276
277       --ls-option=<option>
278              set server CLI option (can be repeated)
279
280       --ls-hover
281              execute hover requests (HTML output only)
282
283       --ls-semantic
284              query server for semantic token types (requires LSP 3.16)
285
286       --ls-syntax=<lang>
287              set syntax which is understood by the server
288
289       --ls-syntax-error
290              retrieve syntax error information (assumes --ls-hover  or  --ls-
291              semantic)
292
293       --ls-workspace=<dir>
294              set workspace directory to initialize the server
295
296

ENV VARIABLES

298       Highlight recognizes these variables:
299
300       HIGHLIGHT_DATADIR
301              sets the path to highlight's configuration scripts
302
303       HIGHLIGHT_OPTIONS
304              may contain command line options, but no input file paths.
305
306

HINTS

308       If  no in- or output files are specified, stdin and stdout will be used
309       for in- or output.  Reading from stdin can also be triggered by the '-'
310       option.
311
312       Default  output format: xterm256 or truecolor if appropriate, HTML oth‐
313       erwise.
314
315       Style definitions are stored in highlight.css  (HTML,  XHTML,  SVG)  or
316       highlight.sty (LaTeX, TeX) if neither -c nor -I is given. For CSS, def‐
317       initions are stored in the output document header with  -I,  if  -f  is
318       also given there will be no style definitions.
319
320       Reformatting  code  (-F)  will only work with C, C++, C# and Java input
321       files.
322
323       LSP features require absolute  input  paths  and  disable  reformatting
324       (-F).
325
326

BUGS

328       Wrapping  lines  with  -V  or -W will cause faulty highlighting of long
329       single line comments and directives.  Using line-range might  interfere
330       with multi line syntax elements. Use with caution.
331

FILES

333       The  configuration files are stored in /usr/share/highlight/.  Language
334       definitions, themes and plugins are located in subdirectories.
335
336       Documentation files are stored in /usr/share/doc/highlight/ ,  configu‐
337       ration files in /etc/highlight/.
338
339       See README how to install own scripts in the home directory.
340

EXAMPLES

342       Single file conversion:
343
344       highlight -o hello.html -i hello.c
345
346       highlight -o hello.html hello.c
347
348       highlight -o hello.html -S c < hello.c
349
350       highlight -S c < hello.c > hello.html
351
352       Note that a file highlight.css is created in the current directory.
353
354       Batch file processing:
355
356       highlight --out-format=xhtml  -B '*.cpp' -d /home/you/html_code/
357
358       converts  all  *.cpp files in the current directory and its subdirecto‐
359       ries to xhtml files, and stores the output in /home/you/html_code.
360
361       highlight --out-format=latex  * -d /home/you/latex_code/
362
363       converts all files to LaTeX, stored in /home/you/latex_code/.
364
365       Use --quiet to improve performance of  batch  file  processing  (recom‐
366       mended for usage in shell scripts).
367
368       Use  highlight  --out-format=xterm256 <yourfile> | less -R to display a
369       source file in a terminal.
370
371       Run highlight --list-scripts=langs to see all supported syntax types.
372
373

AUTHORS

375       Andre Simon <as@andre-simon.de>
376

SEE ALSO

378       README files and http://www.andre-simon.de/.
379
380
381
382Andre Simon                       2021-03-27                      highlight(1)
Impressum