• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

extras/H10-May-2021-6,4724,979

gui_files/H10-May-2021-239238

langDefs/H10-May-2021-19,36516,742

man/H10-May-2021-305275

plugins/H10-May-2021-4,0013,061

src/H03-May-2022-54,79742,260

themes/H10-May-2021-16,12513,412

.editorconfigH A D10-May-20211 KiB6249

.gitlab-ci.ymlH A D10-May-20211.1 KiB3933

AUTHORSH A D10-May-20212.4 KiB9076

COPYINGH A D10-May-202134.3 KiB675553

ChangeLog.adocH A D10-May-202171.5 KiB2,2931,573

INSTALLH A D10-May-20219.3 KiB294209

README.adocH A D10-May-202135 KiB1,008733

README_DE.adocH A D10-May-202136.9 KiB1,027753

README_LANGLIST.adocH A D10-May-202127.6 KiB298286

README_LSP_CLIENT.adocH A D10-May-20214.9 KiB149103

README_PLUGINS.adocH A D10-May-202124.9 KiB732570

README_REGEX.adocH A D10-May-202117.1 KiB466331

README_RELEASE.adocH A D10-May-20212.2 KiB11778

README_TESTCASES.adocH A D10-May-20214.1 KiB13397

README_V4_MIGRATION.adocH A D10-May-20213.5 KiB11283

filetypes.confH A D10-May-20218.7 KiB179171

highlight-langs2adoc.shH A D10-May-20215.1 KiB13759

highlight.desktopH A D10-May-2021428 1211

lsp.confH A D10-May-2021931 2616

makefileH A D03-May-20226.6 KiB182135

validate.shH A D10-May-20212.2 KiB5831

README.adoc

1= HIGHLIGHT MANUAL
2André Simon
3v4.1, April 2021
4:lang: en
5:toc: left
6:toc-title: Contents
7:toclevels: 4
8:sectnums:
9:sectnumlevels: 2
10:sectanchors:
11// Misc Settings:
12:experimental: true
13:icons: font
14:linkattrs: true
15
16// =====================================
17// Custom Attributes for Reference Links
18// =====================================
19// Highlight Docs (asciidoc):
20:README_DE: pass:q[link:README_DE.adoc[`README_DE`]]
21:README_LANGLIST: pass:q[link:README_LANGLIST.adoc[`README_LANGLIST`]]
22:README_PLUGINS: pass:q[link:README_PLUGINS.adoc[`README_PLUGINS`]]
23:README_REGEX: pass:q[link:README_REGEX.adoc[`README_REGEX`]]
24:README_TESTCASES: pass:q[link:README_TESTCASES.adoc[`README_TESTCASES`]]
25:README_LSP_CLIENT: pass:q[link:README_LSP_CLIENT.adoc[`README_LSP_CLIENT`]]
26// Highlight Docs (uncovenrted):
27:INSTALL: pass:q[link:INSTALL[`INSTALL`]]
28// Source files:
29:cpp_qt_lua: pass:q[link:plugins/cpp_qt.lua[`cpp_qt.lua`^]]
30:lsp_conf: pass:q[link:lsp.conf[`lsp.conf`^]]
31:filetypes_conf: pass:q[link:filetypes.conf[`filetypes.conf`^]]
32:fileopenfilter_conf: pass:q[link:gui_files/ext/fileopenfilter.conf[`gui_files/ext/fileopenfilter.conf`^]]
33:makefile: pass:q[link:makefile[`makefile`^]]
34// Folders:
35:langDefs: pass:q[link:langDefs/[`langDefs/`^]]
36:themes: pass:q[link:themes/[`themes/`^]]
37:themes_base16: pass:q[link:themes/base16/[`themes/base16/`^]]
38// Extras Folder:
39:extras: pass:q[link:extras/[`extras/`]]
40:extras_swig: pass:q[link:extras/swig/[`extras/swig/`]]
41:README_SWIG: pass:q[link:extras/swig/README_SWIG[`README_SWIG`]]
42:extras_pandoc: pass:q[link:extras/pandoc/[`extras/pandoc/`]]
43:README_pandoc: pass:q[link:extras/pandoc/README.html[`README.html`]]
44:extras_tcl: pass:q[link:extras/tcl/[`extras/tcl/`]]
45:README_TCL: pass:q[link:extras/tcl/README_TCL[`README_TCL`]]
46// External Links:
47:andre-simon_de: pass:[http://www.andre-simon.de[www.andre-simon.de^]]
48
49
50OSI Certified Open Source Software
51
52Deutsche Anleitung: {README_DE}
53
54
55== OVERVIEW
56
57Highlight converts sourcecode to HTML, XHTML, RTF, ODT, LaTeX, TeX, SVG, BBCode,
58Pango markup and terminal escape sequences with coloured syntax highlighting.
59Syntax definitions and colour themes are customizable.
60
61
62=== INTENDED PURPOSE
63
64Highlight was designed to offer a flexible but easy to use syntax highlighter
65for several output formats. No syntax or colouring information is hardcoded,
66instead all relevant data is stored in configuration scripts. These Lua scripts
67may be altered and enhanced with plug-ins.
68
69
70=== FEATURE LIST
71
72* highlighting of keywords, types, strings, numbers, escape sequences, comments,
73  operators and preprocessor directives
74* coloured output in HTML, XHTML 1.1, RTF, TeX, LaTeX, SVG, BBCode, Pango Markup
75  and terminal escape sequences
76* supports referenced stylesheet files for HTML, LaTeX, TeX or SVG output
77* configuration files are Lua scripts
78* supports plug-in scripts to tweak language definitions and themes
79* syntax elements are defined as regular expressions or plain string lists
80* customizable keyword groups
81* recognition of nested languages within a file
82* reformatting and indentation of C, C++, C# and Java source code
83* wrapping of long lines
84* configurable output of line numbers
85
86
87=== SUPPORTED PROGRAMMING AND MARKUP LANGUAGES
88
89
90Please see {README_LANGLIST} for the current set of supported languages.
91To get a list and associated file extensions you may also run:
92
93..............................
94highlight --list-scripts=langs
95..............................
96
97
98== USAGE AND OPTIONS
99
100=== QUICK INTRODUCTION
101
102The following examples show how to produce a highlighted C++ file, using
103`main.cpp` as input file:
104
105
106Generate HTML::
107+
108.................................................
109highlight -i main.cpp -o main.cpp.html
110highlight < main.cpp > main.cpp.html --syntax cpp
111highlight < source.tmp > main.cpp.html --syntax-by-name main.cpp
112.................................................
113+
114You will find the HTML file and `highlight.css` in the working directory.
115If you use IO redirection (2nd example), you must define the programming
116language with `--syntax` or `--syntax-by-name`.
117
118
119Generate HTML with embedded CSS definitions and line numbers::
120+
121.....................................................................
122highlight -i main.cpp -o main.cpp.html --include-style --line-numbers
123.....................................................................
124
125
126Generate HTML with inline CSS definitions::
127+
128...................................................
129highlight -i main.cpp -o main.cpp.html --inline-css
130...................................................
131
132
133Generate LaTeX using "`horstmann`" source formatting style and "`neon`" colour theme::
134+
135................................................................................
136highlight -O latex -i main.cpp -o main.cpp.tex --reformat horstmann --style neon
137................................................................................
138+
139The following output formats may be defined with `--out-format`:
140+
141[horizontal]
142`html`      ::: HTML5 (default)
143`xhtml`     ::: XHTML 1.1
144`tex`       ::: Plain TeX
145`latex`     ::: LaTeX
146`rtf`       ::: RTF
147`odt`       ::: OpenDocument Text (Flat XML)
148`svg`       ::: SVG
149`bbcode`    ::: BBCode
150`pango`     ::: Pango markup
151`ansi`      ::: Terminal 16 color escape codes
152`xterm256`  ::: Terminal 256 color escape codes
153`truecolor` ::: Terminal 16m color escape codes
154
155
156Customize font settings::
157+
158..........................................................................
159highlight --syntax ada --font-size 12 --font "'Courier New',monospace"
160highlight --syntax ada --out-format=latex --font-size tiny --font sffamily
161..........................................................................
162
163
164Define an output directory::
165+
166.......................................
167highlight -d some/target/dir/ *.cpp *.h
168.......................................
169
170
171
172See `highlight --help` or `man highlight` for more details.
173
174
175=== CLI OPTIONS
176
177The command line version of highlight offers the following options:
178
179................................................................................
180USAGE: highlight [OPTIONS]... [FILES]...
181
182General options:
183
184 -B, --batch-recursive=<wc>     convert all matching files, searches subdirs
185                                  (Example: -B '*.cpp')
186 -D, --data-dir=<directory>     set path to data directory
187     --config-file=<file>       set path to a lang or theme file
188 -d, --outdir=<directory>       name of output directory
189 -h, --help[=topic]             print this help or a topic description
190                                  <topic> = [syntax, theme, plugin, config, test, lsp]
191 -i, --input=<file>             name of single input file
192 -o, --output=<file>            name of single output file
193 -P, --progress                 print progress bar in batch mode
194 -q, --quiet                    suppress progress info in batch mode
195 -S, --syntax=<type|path>       specify type of source code or syntax file path
196     --syntax-by-name=<name>    specify type of source code by given name
197                                  will not read a file of this name, useful for stdin
198     --syntax-supported         test if the given syntax can be loaded
199 -v, --verbose                  print debug info; repeat to show more information
200     --force[=syntax]           generate output if input syntax is unknown
201     --list-scripts=<type>      list installed scripts
202                                  <type> = [langs, themes, plugins]
203     --list-cat=<categories>    filter the scripts by the given categories
204                                  (example: --list-cat='source;script')
205     --max-size=<size>          set maximum input file size
206                                  (examples: 512M, 1G; default: 256M)
207     --plug-in=<script>         execute Lua plug-in script; repeat option to
208                                  execute multiple plug-ins
209     --plug-in-param=<value>    set plug-in input parameter
210     --print-config             print path configuration
211     --print-style              print stylesheet only (see --style-outfile)
212     --skip=<list>              ignore listed unknown file types
213                                  (Example: --skip='bak;c~;h~')
214     --stdout                   output to stdout (batch mode, --print-style)
215     --validate-input           test if input is text, remove Unicode BOM
216     --version                  print version and copyright information
217
218
219Output formatting options:
220
221 -O, --out-format=<format>      output file in given format
222                                  <format>=[html, xhtml, latex, tex, odt, rtf,
223                                  ansi, xterm256, truecolor, bbcode, pango, svg]
224 -c, --style-outfile=<file>     name of style file or print to stdout, if
225                                  'stdout' is given as file argument
226 -e, --style-infile=<file>      to be included in style-outfile (deprecated)
227                                  use a plug-in file instead
228 -f, --fragment                 omit document header and footer
229 -F, --reformat=<style>         reformats and indents output in given style
230                                  <style> = [allman, gnu, google, horstmann,
231                                  java, kr, linux, lisp, mozilla, otbs, pico,
232                                  vtk, ratliff, stroustrup, webkit, whitesmith]
233 -I, --include-style            include style definition in output file
234 -J, --line-length=<num>        line length before wrapping (see -V, -W)
235 -j, --line-number-length=<num> line number width incl. left padding (default: 5)
236     --line-range=<start-end>   output only lines from number <start> to <end>
237 -k, --font=<font>              set font (specific to output format)
238 -K, --font-size=<num?>         set font size (specific to output format)
239 -l, --line-numbers             print line numbers in output file
240 -m, --line-number-start=<cnt>  start line numbering with cnt (assumes -l)
241 -s, --style=<style|path>       set colour style (theme) or theme file path
242 -t, --replace-tabs=<num>       replace tabs by <num> spaces
243 -T, --doc-title=<title>        document title
244 -u, --encoding=<enc>           set output encoding which matches input file
245                                  encoding; omit encoding info if set to NONE
246 -V, --wrap-simple              wrap lines after 80 (default) characters w/o
247                                  indenting function parameters and statements
248 -W, --wrap                     wrap lines after 80 (default) characters
249     --wrap-no-numbers          omit line numbers of wrapped lines
250                                  (assumes -l)
251 -z, --zeroes                   pad line numbers with 0's
252     --isolate                  output each syntax token separately (verbose output)
253     --keep-injections          output plug-in injections in spite of -f
254     --kw-case=<case>           change case of case insensitive keywords
255                                  <case> =  [upper, lower, capitalize]
256     --no-trailing-nl[=mode]    omit trailing newline. If mode is empty-file, omit
257                                  only for empty input
258     --no-version-info          omit version info comment
259
260
261(X)HTML output options:
262
263 -a, --anchors                  attach anchor to line numbers
264 -y, --anchor-prefix=<str>      set anchor name prefix
265 -N, --anchor-filename          use input file name as anchor prefix
266 -C, --print-index              print index with hyperlinks to output files
267 -n, --ordered-list             print lines as ordered list items
268     --class-name=<name>        set CSS class name prefix;
269                                  omit class name if set to NONE
270     --inline-css               output CSS within each tag (verbose output)
271     --enclose-pre              enclose fragmented output with pre tag
272                                  (assumes -f)
273
274
275LaTeX output options:
276
277 -b, --babel                    disable Babel package shorthands
278 -r, --replace-quotes           replace double quotes by \dq{}
279     --beamer                   adapt output for the Beamer package
280     --pretty-symbols           improve appearance of brackets and other symbols
281
282
283RTF output options:
284
285     --page-color               include page color attributes
286 -x, --page-size=<ps>           set page size
287                                  <ps> = [a3, a4, a5, b4, b5, b6, letter]
288     --char-styles              include character stylesheets
289
290
291SVG output options:
292
293     --height                   set image height (units allowed)
294     --width                    set image width (see --height)
295
296
297Terminal escape output options (xterm256 or truecolor):
298
299     --canvas[=width]           set background colour padding (default: 80)
300
301
302Language Server options:
303
304     --ls-profile=<server>      read LSP configuration from lsp.conf
305     --ls-delay=<ms>            set server initialization delay
306     --ls-exec=<bin>            set server executable name
307     --ls-option=<option>       set server CLI option (can be repeated)
308     --ls-hover                 execute hover requests (HTML output only)
309     --ls-semantic              retrieve semantic token types (requires LSP 3.16)
310     --ls-syntax=<lang>         set syntax which is understood by the server
311     --ls-syntax-error          retrieve syntax error information
312                                  (assumes --ls-hover or --ls-semantic)
313     --ls-workspace=<dir>       set workspace directory to init. the server
314................................................................................
315
316=== GUI OPTIONS
317
318The Graphical User Interface offers a subset of the CLI's features. It includes
319a dynamic preview of the output file's apperarance. Please see screenshots and
320screencasts on the project website.
321Invoke highlight-gui with the `--portable` option to let it save its settings
322in the binary's current directory (instead of using the registry).
323
324
325=== INPUT AND OUTPUT
326
327If no input or output file name is defined by `--input` and `--output` options,
328highlight will use stdin and stdout for file processing.
329Since version 3.44, reading from stdin can also be triggered by the `-` option.
330
331If no input filename is defined by `--input` or given at the prompt, highlight is
332not able to determine the language type by means of the file extension (except
333some scripting languages which are figured out by the shebang in the first input
334line). In this case you have to pass highlight the language with `--syntax` or
335`--syntax-by-name` (this usually should be the file suffix of the source file or
336its name, respectively).
337Example: If you want to convert a Python file, highlight needs to load the
338`py.lang` definition. The correct argument of `--syntax` would be `py`.
339
340................................................................................
341highlight test.py
342highlight < test.py --syntax py       # --syntax option necessary
343cat test.py | highlight --syntax py
344................................................................................
345
346If there exist multiple suffixes (like `C`, `cc`, `cpp` and `h` for C++ files),
347they are mapped to a language definition in {filetypes_conf}.
348
349Highlight enters the batch processing mode if multiple input files are given
350or if `--batch-recursive` is set.
351In batch mode, highlight will save the generated files using the original
352filename, appending the extension of the chosen output type.
353If files in the input directories happen to share the same name, the output
354files will be prefixed with their source path name.
355The `--out-dir` option is recommended in batch mode. Use `--quiet` to improve
356performance (recommended for usage in shell scripts).
357
358==== HTML, TeX, LaTeX and SVG output
359
360The HTML, TeX, LaTeX and SVG output formats allow to reference a stylesheet
361file which contains the formatting information.
362
363In HTML and SVG output, this file contains CSS definitions and is saved as
364`highlight.css`. In LaTeX and TeX, it contains macro definitions, and is saved
365as 'highlight.sty'.
366
367Name and path of the stylesheet may be modified with `--style-outfile`.
368If the `--outdir` option is given, all generated output, including stylesheets,
369are stored in this directory.
370
371Use `--include-style` to embed the style information in the output documents
372without referencing a stylesheet.
373
374Referenced stylesheets have the advantage to share all formatting information
375in a single file, which affects all referencing documents.
376
377With `--style-infile` you define a file to be included in the final formatting
378information of the document. This way you enhance or redefine the default
379highlight style definitions without editing generated code.
380Note: Using a plug-in script is the preferred way to enhance styling.
381
382==== Terminal output:
383
384Since there are limited colours defined for ANSI terminal output, there exists
385only one hard coded colour theme with `--out-format=ansi`. You should therefore
386use `--out-format=xterm256` to enable output in 256 colours. The 256 colour mode
387is supported by recent releases of xterm, rxvt and Putty (among others).
388The latest terminal emulators also support 16m colors, this mode is enabled
389with `--out-format=truecolor`.
390
391.....................................................
392highlight --out-format=ansi <inputfile> | less -R
393highlight --out-format=xterm256 <inputfile> | less -R
394.....................................................
395
396==== Text processing:
397
398If the language definition is specified as `txt`, no highlighting takes place.
399
400.......................................................
401highlight -S txt --out-format=latex README > README.tex
402.......................................................
403
404
405=== ADVANCED OPTIONS
406
407==== Prevent parsing of binary input files
408
409If highlight might process untrusted input, you can disable parsing of binary
410files using `--validate-input`. This flag causes highlight to match the input file
411header with a list of magic numbers. If a binary file type is detected, highlight
412quits with an error message. This switch also removes an UTF-8 BOM in the output.
413
414==== Test new configuration scripts
415
416The option `--config-file` helps to test new config files. The argument file must be
417a lang or theme.
418
419...........................................................
420highlight --config-file xxx.lang --config-file yyy.theme -I
421...........................................................
422
423==== Debug language definitions
424
425Use `--verbose` to display Lua and syntax data. Apply twice to print more information.
426
427==== Remove an UTF8 BOM:
428
429Use `--validate-input` to get rid of UTF8 byte order marks.
430
431==== Force output to stdout
432
433Use `--stdout` to write output files in batch mode to stdout.
434
435==== Portable GUI (Windows build)
436
437Invoke highlight-gui.exe with the `--portable` switch to save its configuration
438in text files instead of the registry.
439
440
441=== ENVIRONMENT VARIABLES
442
443The command line version recognizes these variables:
444
445* `HIGHLIGHT_DATADIR`: sets the path to highlight's configuration scripts
446* `HIGHLIGHT_OPTIONS`: may contain command line options, but no input file paths.
447
448=== SYNTAX TESTING
449
450Since version 2.45, highlight supports special notations within comments to
451test its syntax recognition.
452See {README_TESTCASES} for details.
453
454=== LSP CLIENT
455
456Since version 4.0, highlight supports LSP to enhance its output.
457See {README_LSP_CLIENT} for details.
458
459== CONFIGURATION
460
461=== FILE FORMAT
462
463Configuration files are Lua scripts.
464
465For more details about the Lua syntax, please refer to:
466
467* http://www.lua.org/manual/5.1/manual.html
468
469These constructs are sufficient to edit the scripts:
470
471Variable assignment::
472`name = value` +
473(variables have no type, only values have)
474
475Strings::
476`string1="string literal with escape: \n"` +
477`string2=[[raw string without escape sequence]]`
478+
479If raw string content starts with `[` or ends with `]`, pad the parenthesis
480with space to avoid a syntax error. Highlight will strip the string.
481+
482If the string is a regular expression containing a set with a character class
483like [[:space:]], use string delimiters with a "`filler`": +
484`[=[ regex string ]=]`
485
486Comments::
487`-- line comment` +
488`--[[ block comment ]]`
489
490Arrays::
491`array = { first=1, second="2", 3, { 4,5 } }`
492
493
494=== LANGUAGE DEFINITIONS
495
496A language definition describes syntax elements of a programming language which
497will be highlighted by different colours and font types.
498Save the new file in {langDefs}, using the following name convention:
499
500..........................................
501<usual extension of sourcecode files>.lang
502..........................................
503
504Examples:
505
506[horizontal]
507PHP::  -> `php.lang`
508Java:: -> `java.lang`
509
510If there exist multiple suffixes, list them in {filetypes_conf}.
511
512
513==== Syntax elements
514
515................................................................................
516Keywords = { { Id, List|Regex, Group?, Priority?, Constraints? } }
517
518  Id:          Integer, keyword group id (can be reused for several groups).
519               Default themes support 4 and base16 themes 6 groups.
520  List:        List, list of keywords
521  Regex:       String, regular expression
522  Group:       Integer, capturing group id of regular expression, defines part of
523               regex which should be returned as keyword (optional; if not set,
524               the match with the highest group number is returned (counts from
525               left to right))
526  Priority:    Integer, if not zero no more regexes will be evaluated if this
527               regex matches
528  Constraints: table consisting of:
529               Line: Integer, limit match to line number,
530               Filename: String, limit match to input file name
531
532Regular expressions are evaluated in the their order within Keywords. If a regex
533does not appear to match, there might be a conflicting expression listed before.
534
535
536Comments = { {Block, Nested?, Delimiter={Open, Close?} }
537
538  Block:     Boolean, true if comment is a block comment
539  Nested:    Boolean, true if block comments can be nested (optional)
540  Delimiter: List, contains open delimiter regex (line comment) or open and close
541             delimiter regexes (block comment)
542
543
544Strings = { Delimiter|DelimiterPairs={Open, Close, Raw?}, Escape?, Interpolation?,
545            RawPrefix?, AssertEqualLength? }
546
547  Delimiter:         String, regular expression which describes string delimiters
548  DelimiterPairs:    List, includes open and close delimiter expressions if not
549                     equal, includes optional Raw flag as boolean which marks
550                     delimiter pair to contain a raw string
551  Escape:            String, regex of escape sequences (optional)
552  Interpolation:     String, regex of interpolation sequences (optional)
553  RawPrefix:         String, defines raw string indicator (optional)
554  AssertEqualLength: Boolean, set true if delimiters must have the same length
555
556
557PreProcessor = { Prefix, Continuation? }
558
559  Prefix:        String, regular expression which describes open delimiter
560  Continuation:  String, contains line continuation character (optional).
561
562
563NestedSections = {Lang, Delimiter= {} }
564
565  Lang:      String, name of nested language
566  Delimiter: List, contains open and close delimiters of the code section
567
568
569KeywordFormatHints={ { Id, Bold?, Italic?, Underline? } }
570  Id:         Integer, keyword group id whose attributes should be changed
571  Bold:       Boolean, font weight property
572  Italic:     Boolean, font style property
573  Underline:  Boolean, font decoration property
574
575These hints may have no effect if multiple syntax types are highlighted in batch
576mode without --include-style.
577
578Description:       String, Defines syntax description
579
580Categories:        Table, List of categories (config, source, script, etc)
581
582Digits:            String, Regular expression which defines digits (optional)
583
584Identifiers:       String, Regular expression which defines identifiers
585                   (optional)
586
587Operators:         String, Regular expression which defines operators
588
589EnableIndentation: Boolean, set true if syntax may be reformatted and indented
590
591IgnoreCase:        Boolean, set true if keyword case should be ignored
592
593EncodingHint:      String, default input file encoding
594
595................................................................................
596
597
598==== Global variables
599
600The following variables are available within a language definition:
601
602[horizontal]
603`HL_LANG_DIR`:: path of language definition directory (use with Lua dofile function)
604`Identifiers`:: Default regex for identifiers
605`Digits`::      Default regex for numbers
606
607The following integer variables represent the internal highlighting states:
608
609* `HL_STANDARD`
610* `HL_STRING`
611* `HL_NUMBER`
612* `HL_LINE_COMMENT`
613* `HL_BLOCK_COMMENT`
614* `HL_ESC_SEQ`
615* `HL_PREPROC`
616* `HL_PREPROC_STRING`
617* `HL_OPERATOR`
618* `HL_INTERPOLATION`
619* `HL_LINENUMBER`
620* `HL_KEYWORD`
621* `HL_STRING_END`
622* `HL_LINE_COMMENT_END`
623* `HL_BLOCK_COMMENT_END`
624* `HL_ESC_SEQ_END`
625* `HL_PREPROC_END`
626* `HL_OPERATOR_END`
627* `HL_INTERPOLATION_END`
628* `HL_KEYWORD_END`
629* `HL_EMBEDDED_CODE_BEGIN`
630* `HL_EMBEDDED_CODE_END`
631* `HL_IDENTIFIER_BEGIN`
632* `HL_IDENTIFIER_END`
633* `HL_UNKNOWN`
634* `HL_REJECT`
635
636==== The function `OnStateChange`
637
638This function is a hook which is called if an internal state changes (e.g. from
639`HL_STANDARD` to `HL_KEYWORD` if a keyword is found). It can be used to alter
640the new state or to manipulate syntax elements like keyword lists.
641
642[[OnStateChange]]
643................................................................................
644OnStateChange(oldState, newState, token, kwGroupID, lineno, column)
645
646  Hook Event: Highlighting parser state change
647  Parameters: oldState:  old state
648              newState:  intended new state
649              token:     the current token which triggered the new state
650              kwGroupID: if newState is HL_KEYWORD, the parameter
651                         contains the keyword group ID
652              lineno:    line number (since 3.50)
653              column:    line column (since 3.50)
654  Returns:    Correct state to continue OR HL_REJECT
655................................................................................
656
657Return `HL_REJECT` if the recognized token and state should be discarded; the
658first character of token will be outputted and highlighted as `oldState`.
659
660See {README_PLUGINS} for more available functions.
661
662
663.Example
664
665[source,lua]
666--------------------------------------------------------------------------------
667Description="C and C++"
668
669Categories = {"source"}
670
671Keywords={
672  {  Id=1,
673   List={"goto", "break", "return", "continue", "asm", "case", "default",
674         -- [..]
675        }
676  },
677  -- [..]
678}
679
680Strings = {
681  Delimiter=[["|']],
682  RawPrefix="R",
683}
684
685Comments = {
686   { Block=true,
687     Nested=false,
688     Delimiter = { [[\/\*]], [[\*\/]] }  },
689   { Block=false,
690     Delimiter = { [[//]] } }
691}
692
693IgnoreCase=false
694
695PreProcessor = {
696  Prefix=[[#]],
697  Continuation="\\",
698}
699
700Operators=[[\(|\)|\[|\]|\{|\}|\,|\;|\.|\:|\&|\<|\>|\!|\=|\/|\*|\%|\+|\-|\~]]
701
702EnableIndentation=true
703
704-- resolve issue with C++14 number separator syntax
705function OnStateChange(oldState, newState, token)
706
707   if token=="'" and oldState==HL_NUMBER and newState==HL_STRING then
708      return HL_NUMBER
709   end
710
711   return newState
712end
713--------------------------------------------------------------------------------
714
715
716=== REGULAR EXPRESSIONS
717
718Please see {README_REGEX} for the supported regex constructs.
719
720
721=== THEME DEFINITIONS
722
723Colour themes contain the formatting information of the syntax elements which
724are described in language definitions.
725
726The files have to be stored as `.theme` in {themes}.
727Apply a theme with the `--style` option. Prepend `base16/` to the name in order
728to use one of the included Base16 themes (located in {themes_base16}).
729
730
731==== Format attributes
732
733................................................................................
734Attributes = {Colour, Bold?, Italic?, Underline?, Custom? }
735................................................................................
736
737[horizontal]
738Colour::    String, defines colour in HTML hex notation (`#rrggbb`)
739Bold::      Boolean, true if font should be bold (optional)
740Italic::    Boolean, true if font should be italic (optional)
741Underline:: Boolean, true if font should be underlined (optional)
742Custom::    Array, contains `Format` and `Style` for custom styles
743
744==== Theme elements
745
746................................................................................
747Description:   = String, Defines theme description
748
749Categories     = Table, List of categories (dark, light, etc)
750
751Default        = Attributes (Colour of unspecified text)
752
753Canvas         = Attributes (Background colour)
754
755Number         = Attributes (numbers)
756
757Escape         = Attributes (escape sequences)
758
759String         = Attributes (strings)
760
761Interpolation  = Attributes (interpolation sequences)
762
763PreProcessor   = Attributes (preprocessor directives)
764
765StringPreProc  = Attributes (strings within preprocessor directives)
766
767BlockComment   = Attributes (block comments)
768
769LineComment    = Attributes (line comments)
770
771LineNum        = Attributes (line numbers)
772
773Operator       = Attributes (operators)
774
775Hover          = Attributes (LSP Hover elements)
776
777Error          = Attributes (LSP syntax errors)
778
779ErrorMessage   = Attributes (LSP error descriptions)
780
781Keywords= {
782  Attributes1,
783  Attributes2,
784  Attributes3,
785  Attributes4,
786  Attributes5,
787  Attributes6,
788}
789
790AttributesN: Formatting of keyword group N.
791
792SemanticAttributesN: An array consisting of:
793                     `Type`: Token Identifier of the LS protocol (V 3.16)
794                     `Style`: formatting of the token
795................................................................................
796
797.Example
798[source,lua]
799--------------------------------------------------------------------------------
800Description = "vim autumn"
801
802Categories = {"light", "vim"}
803
804Default	= { Colour="#404040" }
805Canvas	= { Colour="#fff4e8" }
806Number	= { Colour="#00884c" }
807Escape	= { Colour="#8040f0" }
808String	= { Colour="#00884c" }
809BlockComment	= { Colour="#ff5050" }
810StringPreProc = String
811LineComment   = BlockComment
812Operator      = { Colour="#513d2b" }
813LineNum      = { Colour="#555555" }
814PreProcessor      = {  Colour="#660000" }
815Interpolation  = { Colour="#CA6DE1" }
816
817Keywords = {
818  { Colour="#80a030" },
819  { Colour="#b06c58" },
820  { Colour="#30a188" },
821  { Colour="#990000" },
822  { Colour="#9a85ff" },
823  { Colour="#85adff" },
824}
825
826-- new LSP based elements:
827
828SemanticTokenTypes = {
829  { Type = 'type', Style = Keywords[2] },
830  { Type = 'class', Style =  Keywords[1] },
831  { Type = 'struct', Style =  Keywords[4] },
832  { Type = 'interface', Style = Keywords[1] },
833  { Type = 'parameter', Style = Keywords[6] },
834  { Type = 'variable', Style = Keywords[5] },
835  { Type = 'enumMember', Style = Keywords[5] },
836  { Type = 'function', Style = Keywords[4] },
837  { Type = 'method', Style = Keywords[4] },
838  { Type = 'keyword', Style =  Keywords[1]},
839  { Type = 'number', Style = Number },
840  { Type = 'regexp', Style = String },
841  { Type = 'operator', Style = Operator },
842}
843
844--ErrorMessage = {
845--  Custom = {
846--    { Format = "html", Style = "color: blue; border:solid 1px blue; margin-left: 3em" }
847--  }
848--}
849--------------------------------------------------------------------------------
850
851=== KEYWORD GROUPS
852
853You may define custom keyword groups and corresponding highlighting styles.
854This is useful if you want to highlight functions of a third party library,
855macros, constants etc.
856
857You define a new group in two steps:
858
8591. Define a new group in your language definition or plug-in:
860+
861[source,lua]
862--------------------------------------------------------------------------------
863table.insert(Keywords, {
864  {Id=5, List = {"ERROR", "DEBUG", "WARN"} }
865})
866--------------------------------------------------------------------------------
867
8682. Add a corresponding highlighting style in your colour theme or plug-in:
869+
870[source,lua]
871--------------------------------------------------------------------------------
872if #Keywords==4 then
873    table.insert(Keywords, {Colour= "#ff0000", Bold=true})
874end
875--------------------------------------------------------------------------------
876
877It is recommended to define keyword groups in user-defined plugin scripts to
878avoid editing of original highlight files.
879See the {cpp_qt_lua} sample plug-in script and {README_PLUGINS} for details.
880
881
882=== PLUG-INS
883
884The `--plug-in` option reads the path of a Lua script which overrides or
885enhances the settings of theme and language definition files. Plug-ins make
886it possible to apply custom settings without the need to edit installed
887configuration files.
888You can apply multiple plugins by using the `--plug-in` option more than once.
889See {README_PLUGINS} for a detailed description and examples of packaged plugins.
890
891
892
893=== FILE MAPPING
894
895The script {filetypes_conf} assigns file extensions and shebang descriptions to
896language definitions.
897A configuration is mandatory only if multiple file extensions are linked to
898one syntax or if a extension is ambiguous. Otherwise the syntax definition whose
899name corresponds to the input file extension will be applied.
900
901Format:
902
903................................................................................
904FileMapping={
905  {  Lang, Filenames|Extensions|Shebang },
906}
907
908Lang:       String, name of language definition
909Filenames:  list of strings, contains filenames referring to "Lang"
910Extensions: list of strings, contains file extensions referring to "Lang"
911Shebang:    String, Regular expression which matches the first line of the input
912            file
913
914Behaviour upon ambiguous file extensions:
915- CLI: the first association listed here will be used
916- GUI: a syntax selection prompt will be shown
917................................................................................
918
919Edit the file {fileopenfilter_conf} to add new syntax types to
920the GUI's file open filter.
921
922
923=== CONFIG FILE SEARCH
924
925Configuration scripts are searched in the following directories:
926
9271. `~/.highlight/`
9282. user defined directory set with `--data-dir`
9293. value of the environment variable `HIGHLIGHT_DATADIR`
9304. `/usr/share/highlight/`
9315. `/etc/highlight/` (default location of `filetypes.conf` and `lsp.conf`)
9326. current working directory (fallback)
933
934These subdirectories are expected to contain the corresponding scripts:
935
936* langDefs: `*.lang`
937* themes: `*.theme`
938* plugins: `*.lua`
939
940A custom `filetypes.conf` may be placed directly in `~/.highlight/`.
941This search order enables you to enhance the installed scripts without the need
942to copy preinstalled files somewhere else.
943
944Use `--print-config` to determine your settings::
945+
946........................
947highlight --print-config
948........................
949
950
951== EMBEDDING HIGHLIGHT
952
953=== SAMPLE SCRIPTS
954
955See the {extras} subdirectory in the highlight package for some scripts in PHP,
956Perl and Python  which invoke highlight and retrieve its output as string.
957These scripts may be used as reference to develop plug-ins for other apps.
958
959=== PANDOC
960
961PP macros file and tutorial are located in {extras_pandoc}.
962See {README_pandoc} for usage instruction and example files as reference.
963
964=== SWIG
965
966A SWIG interface file is located in {extras_swig}.
967See {README_SWIG} for installation instructions and the example scripts in Perl,
968PHP and Python as programming reference.
969
970=== TCL
971
972A TCL extension is located in {extras_tcl}.
973See {README_TCL} for installation instructions.
974
975
976== BUILDING AND INSTALLING
977
978=== PRECOMPILED PACKAGES
979
980The file {INSTALL} describes the installation from source and includes links to
981precompiled packages.
982
983
984=== BUILDING DEPENDENCIES
985
986Highlight is known to compile with gcc and clang.
987
988It depends on Boost headers and Lua 5.x/LuaJit developer packages.
989
990The optional GUI depends on Qt5 developer packages.
991
992Please see the {makefile} for further options.
993
994
995== DEVELOPER CONTACT
996
997Andre Simon
998
999a.simon@mailbox.org
1000
1001{andre-simon_de}
1002
1003Git project with repository, bug tracker:
1004
1005* https://gitlab.com/saalen/highlight/
1006
1007// EOF //
1008

README_DE.adoc

1= HIGHLIGHT HANDBUCH
2André Simon
3v4.1, April 2021
4:lang: de
5:toc: left
6:toc-title: Contents
7:toclevels: 4
8:sectnums:
9:sectnumlevels: 2
10:sectanchors:
11// Misc Settings:
12:experimental: true
13:icons: font
14:linkattrs: true
15
16// =====================================
17// Custom Attributes for Reference Links
18// =====================================
19// Highlight Docs (asciidoc):
20:README: pass:q[link:README.adoc[`README`]]
21:README_LANGLIST: pass:q[link:README_LANGLIST.adoc[`README_LANGLIST`]]
22:README_PLUGINS: pass:q[link:README_PLUGINS.adoc[`README_PLUGINS`]]
23:README_REGEX: pass:q[link:README_REGEX.adoc[`README_REGEX`]]
24:README_TESTCASES: pass:q[link:README_TESTCASES.adoc[`README_TESTCASES`]]
25:README_LSP_CLIENT: pass:q[link:README_LSP_CLIENT.adoc[`README_LSP_CLIENT`]]
26// Highlight Docs ( uncovenrted):
27:INSTALL: pass:q[link:INSTALL[`INSTALL`]]
28// Source files:
29:cpp_qt_lua: pass:q[link:plugins/cpp_qt.lua[`cpp_qt.lua`^]]
30:lsp_conf: pass:q[link:lsp.conf[`lsp.conf`^]]
31:filetypes_conf: pass:q[link:filetypes.conf[`filetypes.conf`^]]
32:fileopenfilter_conf: pass:q[link:gui_files/ext/fileopenfilter.conf[`gui_files/ext/fileopenfilter.conf`^]]
33:makefile: pass:q[link:makefile[`makefile`^]]
34// Folders:
35:langDefs: pass:q[link:langDefs/[`langDefs/`^]]
36:themes: pass:q[link:themes/[`themes/`^]]
37:themes_base16: pass:q[link:themes/base16/[`themes/base16/`^]]
38// Extras Folder:
39:extras: pass:q[link:extras/[`extras/`]]
40:extras_swig: pass:q[link:extras/swig/[`extras/swig/`]]
41:README_SWIG: pass:q[link:extras/swig/README_SWIG[`README_SWIG`]]
42:extras_pandoc: pass:q[link:extras/pandoc/[`extras/pandoc/`]]
43:README_pandoc: pass:q[link:extras/pandoc/README.html[`README.html`]]
44:extras_tcl: pass:q[link:extras/tcl/[`extras/tcl/`]]
45:README_TCL: pass:q[link:extras/tcl/README_TCL[`README_TCL`]]
46// External Links:
47:andre-simon_de: pass:[http://www.andre-simon.de[www.andre-simon.de^]]
48
49
50OSI Certified Open Source Software
51
52English manual: {README}
53
54
55== UEBERSICHT
56
57Highlight konvertiert Sourcecode in XHTML, HTML, RTF, ODT, TeX, LaTeX, SVG,
58BBCode, Pango Markup und Terminal Escape-Sequenzen mit farbiger Syntaxhervorhebung.
59Sprachdefinitionen und Farbstile sind konfigurierbar.
60
61
62=== SINN UND ZWECK
63
64Highlight wurde mit dem Ziel entworfen, einen flexiblen und einfach zu
65bedienenden Syntaxhighlighter fuer mehrere Ausgabeformate anzubieten.
66Statt hartkodierter Sprachbeschreibungen und Farbschemata sind alle wichtigen
67Informationen in Konfigurationsskripten enthalten. Diese Lua-Skripte koennen
68mit Plug-Ins angepasst und erweitert werden.
69
70
71=== FUNKTIONSLISTE
72
73* Hervorhebung von Schluesselwoertern, Typbezeichnern, Strings, Zahlen,
74  Escapesequenzen, Operatoren, Praeprozessor-Direktiven und Kommentaren
75* Farbige Ausgabe in HTML, XHTML, RTF, TeX, LaTeX, SVG, BBCode, Pango Markup und
76  Terminal-Escapesequenzen
77* Speichern von Stylesheets wahlweise in separater Datei oder innerhalb der
78  Ausgabedatei (HTML, LaTeX, TeX, SVG)
79* Alle Konfigurationsdateien sind Lua-Skripte
80* Unterstuetzt Plug-In Skripte zur Anpassung von Sprachdefinitionen und Themes
81* Syntax-Elemente werden als regelaere Ausdruecke oder als Stringlisten
82  beschrieben
83* Erweiterbare Schluesselwort-Gruppen
84* Erkennung mehrerer Sprachen innerhalb einer Datei
85* Neuformatierung und Einrueckung von C, C++, C# und Java Code
86* Umbrechen von langen Zeilen
87* Anpassbare Ausgabe von Zeilennummern
88
89
90=== UNTERSTUETZTE PROGRAMMIER- UND AUSZEICHNUNGSSPRACHEN
91
92Die Liste aller unterstuetzten Sprachen befindet sich in {README_LANGLIST}.
93Das Kommando `highlight --list-scripts=langs` zeigt ebenfalls eine Liste aller
94Sprachen und den verknuepften Dateiendungen.
95
96
97== GEBRAUCH UND OPTIONEN
98
99=== SCHNELLE EINFUEHRUNG
100
101Folgende Beispiele zeigen, wie man die hervorgehobene Ausgabe einer C++-Datei
102namens `main.cpp` erzeugt:
103
104
105HTML ausgeben::
106+
107.................................................
108highlight -i main.cpp -o main.cpp.html
109highlight < main.cpp > main.cpp.html --syntax cpp
110highlight < source.tmp > main.cpp.html --syntax-by-name main.cpp
111.................................................
112+
113Sie werden die HTML-Datei und die CSS-Datei `highlight.css` im aktuellen
114Verzeichnis finden. Falls Sie Eingabe-Umleitung verwenden, geben Sie den
115Typ der Programmiersprache mit `--syntax` oder `--syntax-by-name` an.
116
117HTML mit eingebetteter CSS Definition und Zeilennummerierung ausgeben::
118+
119.....................................................................
120highlight -i main.cpp -o main.cpp.html --include-style --line-numbers
121.....................................................................
122
123HTML mit direkter CSS-Formatierung ausgeben::
124+
125...................................................
126highlight -i main.cpp -o main.cpp.html --inline-css
127...................................................
128
129LaTeX mit Code-Formatierung im "`horstmann`"-Stil und dem Farbschema "Neon"ausgeben::
130+
131................................................................................
132highlight -O latex -i main.cpp -o main.cpp.tex --reformat horstmann --style neon
133................................................................................
134+
135Folgende Ausgabeformate koennen mit `--out-format` bestimmt werden:
136+
137[horizontal]
138`html`:::      HTML5 (Standard)
139`xhtml`:::     XHTML 1.1
140`tex`:::       Plain TeX
141`latex`:::     LaTeX
142`rtf`:::       RTF
143`odt`:::       OpenDocument Text (Flat XML)
144`svg`:::       SVG
145`bbcode`:::    BBCode
146`pango`:::     Pango markup
147`ansi`:::      Terminal 16 color escape codes
148`xterm256`:::  Terminal 256 color escape codes
149`truecolor`::: Terminal 16m color escape codes
150
151Font und Schriftgroesse anpassen::
152+
153..........................................................................
154highlight --syntax ada --font-size 12 --font "'Courier New',monospace"
155highlight --syntax ada --out-format=latex --font-size tiny --font sffamily
156..........................................................................
157
158Ausgabeverzeichnis definieren::
159+
160.......................................
161highlight -d some/target/dir/ *.cpp *.h
162.......................................
163
164
165=== CLI OPTIONEN
166
167Die Kommandozeilenversion von highlight bietet folgende Optionen:
168
169................................................................................
170USAGE: highlight [OPTIONS]... [FILES]...
171
172General options:
173
174 -B, --batch-recursive=<wc>     convert all matching files, searches subdirs
175                                  (Example: -B '*.cpp')
176 -D, --data-dir=<directory>     set path to data directory
177     --config-file=<file>       set path to a lang or theme file
178 -d, --outdir=<directory>       name of output directory
179 -h, --help[=topic]             print this help or a topic description
180                                  <topic> = [syntax, theme, plugin, config, test, lsp]
181 -i, --input=<file>             name of single input file
182 -o, --output=<file>            name of single output file
183 -P, --progress                 print progress bar in batch mode
184 -q, --quiet                    suppress progress info in batch mode
185 -S, --syntax=<type|path>       specify type of source code or syntax file path
186     --syntax-by-name=<name>    specify type of source code by given name
187                                  will not read a file of this name, useful for stdin
188     --syntax-supported         test if the given syntax can be loaded
189 -v, --verbose                  print debug info; repeat to show more information
190     --force[=syntax]           generate output if input syntax is unknown
191     --list-scripts=<type>      list installed scripts
192                                  <type> = [langs, themes, plugins]
193     --list-cat=<categories>    filter the scripts by the given categories
194                                  (example: --list-cat='source;script')
195     --max-size=<size>          set maximum input file size
196                                  (examples: 512M, 1G; default: 256M)
197     --plug-in=<script>         execute Lua plug-in script; repeat option to
198                                  execute multiple plug-ins
199     --plug-in-param=<value>    set plug-in input parameter
200     --print-config             print path configuration
201     --print-style              print stylesheet only (see --style-outfile)
202     --skip=<list>              ignore listed unknown file types
203                                  (Example: --skip='bak;c~;h~')
204     --stdout                   output to stdout (batch mode, --print-style)
205     --validate-input           test if input is text, remove Unicode BOM
206     --version                  print version and copyright information
207
208
209Output formatting options:
210
211 -O, --out-format=<format>      output file in given format
212                                  <format>=[html, xhtml, latex, tex, odt, rtf,
213                                  ansi, xterm256, truecolor, bbcode, pango, svg]
214 -c, --style-outfile=<file>     name of style file or print to stdout, if
215                                  'stdout' is given as file argument
216 -e, --style-infile=<file>      to be included in style-outfile (deprecated)
217                                  use a plug-in file instead
218 -f, --fragment                 omit document header and footer
219 -F, --reformat=<style>         reformats and indents output in given style
220                                  <style> = [allman, gnu, google, horstmann,
221                                  java, kr, linux, lisp, mozilla, otbs, pico,
222                                  vtk, ratliff, stroustrup, webkit, whitesmith]
223 -I, --include-style            include style definition in output file
224 -J, --line-length=<num>        line length before wrapping (see -V, -W)
225 -j, --line-number-length=<num> line number width incl. left padding (default: 5)
226     --line-range=<start-end>   output only lines from number <start> to <end>
227 -k, --font=<font>              set font (specific to output format)
228 -K, --font-size=<num?>         set font size (specific to output format)
229 -l, --line-numbers             print line numbers in output file
230 -m, --line-number-start=<cnt>  start line numbering with cnt (assumes -l)
231 -s, --style=<style|path>       set colour style (theme) or theme file path
232 -t, --replace-tabs=<num>       replace tabs by <num> spaces
233 -T, --doc-title=<title>        document title
234 -u, --encoding=<enc>           set output encoding which matches input file
235                                  encoding; omit encoding info if set to NONE
236 -V, --wrap-simple              wrap lines after 80 (default) characters w/o
237                                  indenting function parameters and statements
238 -W, --wrap                     wrap lines after 80 (default) characters
239     --wrap-no-numbers          omit line numbers of wrapped lines
240                                  (assumes -l)
241 -z, --zeroes                   pad line numbers with 0's
242     --isolate                  output each syntax token separately (verbose output)
243     --keep-injections          output plug-in injections in spite of -f
244     --kw-case=<case>           change case of case insensitive keywords
245                                  <case> =  [upper, lower, capitalize]
246     --no-trailing-nl[=mode]    omit trailing newline. If mode is empty-file, omit
247                                  only for empty input
248     --no-version-info          omit version info comment
249
250
251(X)HTML output options:
252
253 -a, --anchors                  attach anchor to line numbers
254 -y, --anchor-prefix=<str>      set anchor name prefix
255 -N, --anchor-filename          use input file name as anchor prefix
256 -C, --print-index              print index with hyperlinks to output files
257 -n, --ordered-list             print lines as ordered list items
258     --class-name=<name>        set CSS class name prefix;
259                                  omit class name if set to NONE
260     --inline-css               output CSS within each tag (verbose output)
261     --enclose-pre              enclose fragmented output with pre tag
262                                  (assumes -f)
263
264
265LaTeX output options:
266
267 -b, --babel                    disable Babel package shorthands
268 -r, --replace-quotes           replace double quotes by \dq{}
269     --beamer                   adapt output for the Beamer package
270     --pretty-symbols           improve appearance of brackets and other symbols
271
272
273RTF output options:
274
275     --page-color               include page color attributes
276 -x, --page-size=<ps>           set page size
277                                  <ps> = [a3, a4, a5, b4, b5, b6, letter]
278     --char-styles              include character stylesheets
279
280
281SVG output options:
282
283     --height                   set image height (units allowed)
284     --width                    set image width (see --height)
285
286
287Terminal escape output options (xterm256 or truecolor):
288
289     --canvas[=width]           set background colour padding (default: 80)
290
291
292Language Server options:
293
294     --ls-profile=<server>      read LSP configuration from lsp.conf
295     --ls-delay=<ms>            set server initialization delay
296     --ls-exec=<bin>            set server executable name
297     --ls-option=<option>       set server CLI option (can be repeated)
298     --ls-hover                 execute hover requests (HTML output only)
299     --ls-semantic              retrieve semantic token types (requires LSP 3.16)
300     --ls-syntax=<lang>         set syntax which is understood by the server
301     --ls-syntax-error          retrieve syntax error information
302                                  (assumes --ls-hover or --ls-semantic)
303     --ls-workspace=<dir>       set workspace directory to init. the server
304................................................................................
305
306
307=== GUI OPTIONEN
308
309Die graphische Oberflaeche bietet eine Teilmenge der CLI-Funktionen. Sie enthaelt
310eine dynamische Vorschau der sichtbaren Ausgabe. Auf der Projekt-Webseite finden
311Sie Screenshots und Screencasts.
312Wird highlight-gui mit der Option `--portable` gestartet, speichert es die
313Einstellungen im Programmverzeichnis (anstatt zB. die Registry zu benutzen).
314
315
316=== EIN- UND AUSGABE
317
318Wenn kein Dateiname mit `--input` bzw. `--output` angegeben wird, benutzt highlight
319stdin bzw. stdout fuer die Ein- und Ausgabe.
320Seit Version 3.44 wird das Lesen von stdin auch durch die Option "-" ausgeloest.
321
322Wird die Eingabedatei nicht direkt auf der Kommandozeile als Argument bzw. mit
323`--input` angegeben, kann Highlight die passende Sprachinformation nicht
324automatisch anhand der Dateiendung bestimmen. Lediglich einige Skriptsprachen
325werden anhand des Shebangs in der ersten Zeile erkannt.
326Mit der Option `--syntax` oder `--syntax-by-name` muss dann der Typ der Datei
327vom Benutzer angegeben werden (das Argument ist normalerweise die fuer die
328Programmiersprache uebliche Dateierweiterung bzw. der Dateiname).
329Beispiel: Wenn Sie eine Python-Datei konvertieren wollen, muss highlight die
330Sprachdefinition py.lang einlesen. Das korrekte Argument fuer `--syntax` ist
331also `py`.
332
333................................................................................
334highlight test.py                   # Option --syntax nicht noetig
335highlight < test.py --syntax py     # --syntax muss angegeben werden
336cat test.py | highlight --syntax py
337................................................................................
338
339Sollte es mehrere Dateierweiterungen fuer Dateien einer Programmiersprache
340geben (wie z.B. `C`, `cc`, `cpp`, `h` bei C++), werden diese in der Datei
341{filetypes_conf} einer Sprachdefinition zugewiesen.
342
343Wenn mehrere Eingabedateien an Highlight uebergeben werden oder `--batch-recursive`
344gesetzt ist, wechselt das Tool in den Batch-Modus. In diesem Modus werden die
345Ausgabedateien unter dem Namen der Eingabedateien gespeichert, zusaetzlich wird
346die Dateierweiterung des gewaehlten Ausgabeformats angehangen.
347Sollte es in den Eingabeverzeichnissen Dateien mit identischem Namen geben, so
348werden diese Ausgabedateien mit ihrem Quellverzeichnis als Praefix ausgegeben.
349Die `--outdir` Option ist im Batch Modus besonders nuetzlich. In Skripten sollte
350`--quiet` angegeben werden, um die Geschwindigkeit der Verarbeitung zu erhoehen.
351
352
353==== HTML, TeX, LaTeX und SVG Ausgabe:
354
355Die HTML, TeX, LaTeX und SVG-Formate erlauben die Einbindung von Stylesheets,
356welche die Formatierungsinformationen enthalten.
357
358Bei der HTML- und SVG-Ausgabe enthaelt diese Datei CSS-Definitionen und wird, wenn
359nicht anders angegeben, als "highlight.css" gespeichert. Bei TeX und LaTeX enthaelt
360die Datei Makros, und wird per Default als "highlight.sty" gespeichert.
361
362Name und Pfad des Stylesheets werden mit `--style-outfile` bestimmt.
363Wenn `--outdir` definiert ist, wird auch das Stylesheet im angegebenen
364Ausgabeverzeichnis gespeichert.
365
366Mit `--include-style` fuegt Highlight die Formatierungsangaben direkt in die
367Ausgabedokumente ein, statt einen Verweis auf externe Stylesheets zu setzen.
368
369Der Verweis auf externe Dateien hat den Vorteil, die Formatierung an einer
370zentralen Stelle verwalten zu koennen, auf die alle Ausgabedokumente verweisen.
371
372Mit `--style-infile` kann eine Datei mit zusaetzlichen Formatierungsangaben in
373die Ausgabedateien eingebunden werden, welche die vorgegebene highlight-
374Formatierung erweitert oder ueberschreibt.
375Hinweis: Ein Plug-In Skript ist die bessere Methode das Styling anzupassen.
376
377
378==== Terminal-Ausgabe:
379
380Da es nur wenige Farben zur ANSI-Ausgabe im Terminal gibt, existiert nur ein
381hartkodiertes Farbschema fuer `--out-format=ansi`. Daher sollte nach Moeglichkeit
382`--out-format=xterm256` verwendet werden, um eine Ausgabe in 256 Farben zu erhalten.
383Der 256 Farb-Modus wird z.B. von xterm, rxvt und Putty unterstuetzt.
384Neuere Terminal-Emulatoren unterstuetzen auch 16 Millionen Farben, dies wird mit
385`--out-format=truecolor` aktiviert.
386
387.....................................................
388highlight --out-format=ansi <inputfile> | less -R
389highlight --out-format=xterm256 <inputfile> | less -R
390.....................................................
391
392==== Text-Ausgabe:
393
394Wird als Sprachdefinition txt angegeben, findet keine Syntaxhervorhebung statt.
395
396.......................................................
397highlight -S txt --out-format=latex README > readme.tex
398.......................................................
399
400
401=== FORTGESCHRITTENE OPTIONEN
402
403==== Parsen von Binaerdaten vermeiden
404
405Wird highlight mit unbekannten Eingabedaten aufgerufen, verhindert
406`--validate-input` die Verarbeitung von binaeren Daten.
407Dieser Schalter fuehrt zu einem Vergleich der Datei-Header mit einer Liste von
408"Magic Numbers". Wenn ein Binaer-Typ erkannt wird, bricht highlight die
409Verarbeitung mit einer Fehlermeldung ab.
410Mit `--validate-input` wird zusaetzlich der UTF-8 BOM in der Ausgabe unterdrueckt.
411
412==== Neue Konfigurationsskripte testen:
413
414Die Option `--config-file` ermoeglicht es, neue Skripte vor der Installation zu
415testen. Die Datei muss eine lang- oder theme-Datei sein.
416
417...........................................................
418highlight --config-file xxx.lang --config-file yyy.theme -I
419...........................................................
420
421==== Sprachdefinitionen debuggen:
422
423Benutzen Sie `--verbose`, um Lua- und Syntax-Daten anzuzeigen. Zweifach angeben
424um mehr Informationen zu erhalten.
425
426==== UTF8 BOM entfernen:
427
428Geben Sie `--validate-input` an, um das UTF8 Byte Order Mark (Startsequenz) zu
429entfernen.
430
431==== Ausgabe in stdout erzwingen
432
433Mit `--stdout` wird die Ausgabe auch im Batch-Modus nach stdout ausgegeben.
434
435==== Portable GUI (Windows build)
436
437Starten Sie highlight-gui.exe mit der `--portable` Option, damit die
438Konfiguration in Textdateien und nicht in der Registry gespeichert wird.
439
440=== UMGEBUNGSVARIABLEN
441
442Die Kommandozeilenversion beruecksichtigt folgende Variablen:
443
444* `HIGHLIGHT_DATADIR`: setzt den Pfad zum Konfigurationsverzeichnis
445* `HIGHLIGHT_OPTIONS`: kann Kommandozeilenoptionen enthalten, aber keine Pfade zu Eingabedateien
446
447=== SYNTAXTESTS
448
449Seit Version 2.45 unterstuetzt highlight spezielle Sequenzen in Kommentaren,
450um die eigene Syntaxerkennung zu testen. Mehr dazu in {README_TESTCASES}.
451
452=== LSP-CLIENT
453
454Seit Version 4.0 unterstuetzt highlight LSP, um die Ausgabe zu erweitern.
455Mehr dazu in {README_LSP_CLIENT}.
456
457== KONFIGURATION
458
459=== DATEIFORMAT
460
461Die Konfigurationsdateien sind Lua Skripte.
462Deutsche Einfuehrung in die Syntax:
463
464* link:https://web.archive.org/web/20180323131013/http://www.fh-wedel.de/~si/seminare/ws09/Ausarbeitung/09.lua/lua1.htm[+http://www.fh-wedel.de/~si/seminare/ws09/Ausarbeitung/09.lua/lua1.htm+^]
465
466Das vollstaendige Lua-Handbuch befindet sich hier:
467
468* http://www.lua.org/manual/5.1/manual.html
469
470Folgende Syntax-Elemente genuegen, um die Skripte anzupassen:
471
472
473Wertzuweisung an Variablen::
474`name = value` +
475(Variablen haben keinen Typ, nur Werte haben einen)
476
477Strings::
478`string1="string-Literal mit Escape-Sequenzen: \n"` +
479`string2=[[Raw String ohne Escape-Sequenzen]]`
480+
481Wenn ein Raw-String mit "[" beginnt oder mit "]" endet, muss die Klammer mit
482Leerzeichen von den Begrenzern getrennt werden, um Syntaxfehler zu vermeiden.
483Highlight entfernt diese Leerzeichen beim Einlesen.
484+
485Ist der String ein regulaerer Ausdruck mit einem Ausdruck wie [[:space:]],
486muss der Stringbegrenzer mit einem "Fueller" verwendet werden: +
487`[=[ regex string ]=]`
488
489Kommentare::
490`-- Einzeiliger Kommentar` +
491`--[[ Blockkommentar ]]`
492
493Arrays::
494`array = { first=1, second="2", 3, { 4,5 } }`
495
496
497=== SPRACHDEFINITIONEN
498
499Eine Sprachdefinition beschreibt Syntax-Elemente einer Programmiersprache, die
500durch verschiedene Farben und Schrifttypen hervorgehoben werden.
501Die Datei muss in {langDefs} unter folgendem Namen gespeichert werden:
502
503.................................................
504<uebliche Erweiterung der Sourcecodedateien>.lang
505.................................................
506
507Beispiele:
508
509[horizontal]
510PHP::  -> `php.lang`
511Java:: -> `java.lang`
512
513Sollte es mehrere gebrauechliche Erweiterungen geben, werden diese in der Datei
514{filetypes_conf} einer Sprachdefinition zugeordnet.
515
516
517==== Syntax-Elemente
518
519................................................................................
520Keywords = { { Id, List|Regex, Group?, Priority?, Constraints? } }
521
522  Id:          Integer, ID der Schluesselwortgruppe (mehrfach verwendbar)
523               Default-Themes unterstuetzen 4  Gruppen, Base16-Themes 6.
524  List:        Liste, Auflistung von Schluesselwoertern
525  Regex:       String, Regulaerer Ausdruck
526  Group:       Integer, Capturing Group ID der Regex, bestimmt den Teil des
527               gefundenen Ausdrucks, der als Schluesselwort hervorgehoben werden
528               soll (optional, wenn nicht gesetzt wird der Match mit der
529               hoechsten Group-ID zurueckgegeben (Zaehlung von links nach rechts))
530  Priority:    Integer, wenn nicht Null werden keine weiteren Ausdruecke
531               ausgewertet wenn diese Regex einen Treffer liefert
532  Constraints: Tabelle, bestehend aus:
533               Line: Integer, begrenzt Suche auf die Zeilennummer,
534               Filename: String, begrenzt Suche auf den DAteinamen
535
536Regulaere Ausdruecke werden in ihrer Reihenfolge innerhalb von Keywords ausgewertet.
537Sollte ein Ausdruck nicht funktionieren, koennte ein vorher definierter Ausdruck
538ebenfalls matchen und einen Konflikt ausloesen.
539
540Comments = { {Block, Nested?, Delimiter} }
541
542  Block:     Boolean, true wenn der Kommentar ein Blockkommentar ist
543  Nested:    Boolean, true wenn der Blockkommentar verschachtelt werden darf (optional)
544  Delimiter: Liste, enthaelt Regex der oeffnenden Begrenzer (Zeilenkommentar) oder
545             Regex des oeffnenden und des schliessenden Begrenzers (Blockkommentar)
546
547
548Strings = { Delimiter|DelimiterPairs={Open, Close, Raw?}, Escape?, Interpolation?,
549            RawPrefix?, AssertEqualLength? }
550
551  Delimiter:         String, Regulaerer Ausdruck der Begrenzer
552  DelimiterPairs:    Liste, enthaelt Ausdruecke der oeffnenden und der schliessenden
553                     Begrenzer wenn diese nicht gleich sind und optional ein Raw-
554                     String Flag
555  Escape:            String, Regulaerer Ausdruck fuer Escapsesequenzen (optional)
556  Interpolation:     String, Regulaerer Ausdruck fuer Interpolation (optional)
557  RawPrefix:         String, definiert Raw String Prefix (optional)
558  AssertEqualLength: Boolean, True wenn die Begrenzer gleich lang sein muessen
559
560
561PreProcessor = { Prefix, Continuation? }
562
563  Prefix:        String, Regulaerer Ausdruck der oeffnenden Begrenzer
564  Continuation:  String, Definiert Fortsetzungsindikator (optional)
565
566
567NestedSections = {Lang, Delimiter= {} }
568
569  Lang:      String, Name der eingebetteten Sprache
570  Delimiter: Liste, Ausdruecke der oeffnenden und der schliessenden Begrenzer
571
572
573KeywordFormatHints={ { Id, Bold?, Italic?, Underline? } }
574  Id:         Integer, Id der Schluesselwortgruppe deren Attribute geaendert werden
575  Bold:       Boolean, font weight property
576  Italic:     Boolean, font style property
577  Underline:  Boolean, font decoration property
578
579Diese Angaben werden bei gemischten Syntaxtypen im Batch-Modus ohne --include-style
580nicht in allen Faellen uebernommen.
581
582
583Description:       String, Beschreibung der Syntax
584
585Categories:        Table, Liste von Kategorien (config, source, script, etc)
586
587Digits:            String, Regulaerer Ausdruck fuer Zahlenliterale (optional)
588
589Identifiers:       String, Regulaerer Ausdruck fuer Bezeichner (optional)
590
591Operators:         String, Regulaerer Ausdruck fuer Operatoren
592
593EnableIndentation: Boolean, True wenn Syntax formatiert und eingerueckt werden kann
594
595IgnoreCase:        Boolean, True wenn Sprache nicht case-sensitive ist
596
597EncodingHint:      String, Standard-Eingabeencoding
598
599................................................................................
600
601
602==== Globale Variablen
603
604Die folgenden Variablen sind in einer Sprachbeschreibung verfuegbar:
605
606[horizontal]
607`HL_LANG_DIR`:: Verzeichnis der Sprachdefinitionen (Parameter der Lua dofile-Funktion)
608`Identifiers`:: Default regex fuer Bezeichner
609`Digits`::      Default regex fuer Zahlenliterale
610
611Diese Integer-Variablen beschreiben die internen Zustaende des highlight-Parsers:
612
613* `HL_STANDARD`
614* `HL_STRING`
615* `HL_NUMBER`
616* `HL_LINE_COMMENT`
617* `HL_BLOCK_COMMENT`
618* `HL_ESC_SEQ`
619* `HL_PREPROC`
620* `HL_PREPROC_STRING`
621* `HL_OPERATOR`
622* `HL_INTERPOLATION`
623* `HL_LINENUMBER`
624* `HL_KEYWORD`
625* `HL_STRING_END`
626* `HL_LINE_COMMENT_END`
627* `HL_BLOCK_COMMENT_END`
628* `HL_ESC_SEQ_END`
629* `HL_PREPROC_END`
630* `HL_OPERATOR_END`
631* `HL_KEYWORD_END`
632* `HL_INTERPOLATION_END`
633* `HL_EMBEDDED_CODE_BEGIN`
634* `HL_EMBEDDED_CODE_END`
635* `HL_IDENTIFIER_BEGIN`
636* `HL_IDENTIFIER_END`
637* `HL_UNKNOWN`
638* `HL_REJECT`
639
640
641==== Die Funktion `OnStateChange`
642
643Dieser Hook wird bei Zustandsuebergaengen des Parsers aufgerufen (z.B. beim
644Wechsel von `HL_STANDARD` zu `HL_KEYWORD` wenn ein Schluesselwort erkannt wurde).
645Mit dieser Funktion kann der neue Zustand angepasst werden, oder es koennen
646Syntax-Elemente wie Keyword-Listen erweitert werden.
647
648[[OnStateChange]]
649................................................................................
650OnStateChange(oldState, newState, token, kwGroupID, lineno, column)
651
652  Hook Event: Zustandswechsel des Parsers
653  Parameters: oldState:  bisheriger Zustand
654              newState:  geplanter neuer Zustand
655              token:     das Token welches den Wechsel ausgeloest hat
656              kwGroupID: Wenn newState = HL_KEYWORD, enthaelt dieser Parameter
657                         die Gruppen-ID
658              lineno:    Zeilennummer (seit 3.50)
659              column:    Zeilenspalte (seit 3.50)
660  Returns:    den korrekten Zustand zum fortfahren ODER HL_REJECT
661................................................................................
662
663`HL_REJECT` wird dann zurueckgegeben, wenn das Token und der erkannte Zustand
664verworfen werden sollen; das erste Zeichen von Token wird dann ausgegeben und
665als `oldState` hervorgehoben.
666
667Weitere Funktionen sind in {README_PLUGINS} beschrieben.
668
669
670.Example
671
672[source,lua]
673--------------------------------------------------------------------------------
674Description="C and C++"
675
676Categories = {"source"}
677
678Keywords={
679  {  Id=1,
680   List={"goto", "break", "return", "continue", "asm", "case", "default",
681         -- [..]
682        }
683  },
684  -- [..]
685}
686
687Strings = {
688  Delimiter=[["|']],
689  RawPrefix="R",
690}
691
692Comments = {
693   { Block=true,
694     Nested=false,
695     Delimiter = { [[\/\*]], [[\*\/]] }  },
696   { Block=false,
697     Delimiter = { [[//]] } }
698}
699
700IgnoreCase=false
701
702PreProcessor = {
703  Prefix=[[#]],
704  Continuation="\\",
705}
706
707Operators=[[\(|\)|\[|\]|\{|\}|\,|\;|\.|\:|\&|\<|\>|\!|\=|\/|\*|\%|\+|\-|\~]]
708
709EnableIndentation=true
710
711-- resolve issue with C++14 number separator syntax
712function OnStateChange(oldState, newState, token)
713
714   if token=="'" and oldState==HL_NUMBER and newState==HL_STRING then
715      return HL_NUMBER
716   end
717
718   return newState
719end
720--------------------------------------------------------------------------------
721
722
723=== REGULAERE AUSDRUECKE
724
725Die Datei {README_REGEX} beschreibt alle unterstuetzten Ausdruecke.
726
727
728=== FARBDEFINITIONEN
729
730Farbdefinitionen legen die Formatierung der Sprachelemente fest, die in den
731Sprachdefinitionen beschrieben wurden.
732
733Die Dateien muessen mit der Endung `.theme` in {themes} gespeichert werden.
734Mit der `--style` (`-s`) Option wird das Farbschema angewandt. Setze `base16/` vor
735den Namen, um eines der Base16 Themes zu benutzen (gespeichert in {themes_base16}).
736
737
738==== Formatattribute
739
740................................................................................
741Attributes = {Colour, Bold?, Italic?, Underline? }
742................................................................................
743
744[horizontal]
745Colour::    String, Farbe in Hex-Notation (`#rrggbb`)
746Bold::      Boolean, True wenn Font bold sein soll (optional)
747Italic::    Boolean, True wenn Font kursiv sein soll (optional)
748Underline:: Boolean, True wenn Font unterstrichen sein soll (optional)
749Custom::    Array, enthaelt `Format` und `Style`` Attribute fuer spezielle Formatierungen
750
751==== Theme-Elemente
752
753................................................................................
754Description    = String, Theme-Beschreibung
755
756Categories     = Table, Liste von Kategorien (dark, light, etc)
757
758Default        = Attributes (Farbe des nicht hervorgehobenen Texts)
759
760Canvas         = Attributes (Hintergrundfarbe)
761
762Number         = Attributes (Zahlen)
763
764Escape         = Attributes (Escape-Sequenzen)
765
766String         = Attributes (Strings)
767
768Interpolation  = Attributes (Interpolationen)
769
770PreProcessor   = Attributes (Praeprozessor-Direktiven)
771
772StringPreProc  = Attributes (Strings in Praeprozessor-Direktiven)
773
774BlockComment   = Attributes (Blockkommentare)
775
776LineComment    = Attributes (Zeilenkommentare)
777
778LineNum        = Attributes (Zeilennummern)
779
780Operator       = Attributes (Operatoren)
781
782Hover          = Attributes (LSP Hover Elemente)
783
784Error          = Attributes (LSP Syntaxfehler)
785
786ErrorMessage   = Attributes (LSP Fehlerbeschreibungen)
787
788Keywords= {
789  Attributes1,
790  Attributes2,
791  Attributes3,
792  Attributes4,
793  Attributes5,
794  Attributes6,
795}
796
797SemanticTokenTypes  = {
798  SemanticAttributes1,
799  SemanticAttributes2
800}
801
802AttributesN: Liste, Formatierung von Schluesselwoertgruppen. Es sollten
803             mindestens vier Elemente angegeben werden, um mit der Anzahl
804             von Schluesselwortgruppen in den Sprachdefinitionen
805             uebereinzustimmen.
806
807SemanticAttributesN: Ein Array bestehend aus diesen Elementen:
808                     `Type`: Der Token Identifier des LS-Protokolls (V 3.16)
809                     `Style`: Die Formatierung des Tokens
810
811................................................................................
812
813.Example
814[source,lua]
815--------------------------------------------------------------------------------
816Description = "vim autumn"
817
818Categories = {"light", "vim"}
819
820Default	= { Colour="#404040" }
821Canvas	= { Colour="#fff4e8" }
822Number	= { Colour="#00884c" }
823Escape	= { Colour="#8040f0" }
824String	= { Colour="#00884c" }
825BlockComment	= { Colour="#ff5050" }
826StringPreProc = String
827LineComment   = BlockComment
828Operator      = { Colour="#513d2b" }
829LineNum      = { Colour="#555555" }
830PreProcessor      = {  Colour="#660000" }
831Interpolation  = { Colour="#CA6DE1" }
832
833Keywords = {
834  { Colour="#80a030" },
835  { Colour="#b06c58" },
836  { Colour="#30a188" },
837  { Colour="#990000" },
838  { Colour="#9a85ff" },
839  { Colour="#85adff" },
840}
841
842-- new LSP based elements:
843
844SemanticTokenTypes = {
845  { Type = 'type', Style = Keywords[2] },
846  { Type = 'class', Style =  Keywords[1] },
847  { Type = 'struct', Style =  Keywords[4] },
848  { Type = 'interface', Style = Keywords[1] },
849  { Type = 'parameter', Style = Keywords[6] },
850  { Type = 'variable', Style = Keywords[5] },
851  { Type = 'enumMember', Style = Keywords[5] },
852  { Type = 'function', Style = Keywords[4] },
853  { Type = 'method', Style = Keywords[4] },
854  { Type = 'keyword', Style =  Keywords[1]},
855  { Type = 'number', Style = Number },
856  { Type = 'regexp', Style = String },
857  { Type = 'operator', Style = Operator },
858}
859
860--ErrorMessage = {
861--  Custom = {
862--    { Format = "html", Style = "color: blue; border:solid 1px blue; margin-left: 3em" }
863--  }
864--}
865--------------------------------------------------------------------------------
866
867
868=== SCHLUESSELWORTGRUPPEN
869
870Sie koennen eigene Schluesselwort-Gruppen festlegen und jeder Gruppe eine eigene
871Formatierung zuweisen. Das ist nuetzlich wenn Sie z.B. Bibliotheksfunktionen,
872Makros oder Konstanten gesondert hervorheben moechten.
873
874Eine Gruppe wird in zwei Schritten definiert:
875
876
8771. Beschreibung der Gruppe in der Sprachdefinition:
878+
879[source,lua]
880--------------------------------------------------------------------------------
881Keywords = {
882  -- fuegen Sie die Beschreibung an:
883  {Id=5, List = {"ERROR", "DEBUG", "WARN"} }
884}
885--------------------------------------------------------------------------------
886
887
8882. Festlegung des dazugehoerigen Farbstils im Farb-Schema:
889+
890[source,lua]
891--------------------------------------------------------------------------------
892Keywords= {
893  --Stil als fuenften Eintrag hinterlegen:
894  { Colour= "#ff0000", Bold=true },
895}
896--------------------------------------------------------------------------------
897
898Es wird empfohlen, eigene Keyword-Gruppen in Plugin-Skripten zu definieren,
899um keine Original-Dateien zu veraendern.
900Weitere Infos finden sich im {cpp_qt_lua} Beispiel-Plugin sowie in {README_PLUGINS}.
901
902
903=== PLUG-INS
904
905Die `--plug-in` Option erwartet den Pfad eines Lua Skripts, das Elemente einer
906Sprachdefinition oder eines Themes ueberschreibt oder erweitert.
907Mit Hilfe dieser Plugins kann die Ausgabe angepasst werden, ohne installierte
908Konfigurations-Dateien zu aendern.
909Man kann mehrere Plugins anwenden, indem die `--plug-in` Option wiederholt
910angegeben wird.
911
912Siehe {README_PLUGINS} um mehr darueber zu erfahren.
913
914
915=== DATEIZUORDNUNGEN
916
917In {filetypes_conf} werden Dateizuordnungen und Shebang-Definitionen eingetragen.
918Eine Konfiguration ist nur dann zwingend notwendig, wenn es mehrere Dateiendungen
919fuer eine Syntax gibt oder eine Endung nicht eindeutig zugewiesen werden kann.
920Ansonsten wird die Syntax geladen, deren Name mit der Dateiendung der Eingabedatei
921uebereinstimmt.
922
923Format:
924
925................................................................................
926FileMapping={
927  {  Lang, Filenames|Extensions|Shebang },
928}
929
930Lang:       String, Name der Sprachdefinition
931Filenames:  Liste, enthaelt alle Dateinamen, die "Lang" zugeordnet werden
932Extensions: Liste, enthaelt alle Dateiendungen, die "Lang" zugeordnet werden
933Shebang:    String, Regulaerer Ausdruck der mit der ersten Zeile der Eingabe
934            verglichen wird
935
936Verhalten der Software bei mehrdeutigen Endungen:
937- CLI: die erste eingetragene Verknuepfung wird angewandt
938- GUI: eine Syntax-Auswahl wird angezeigt
939................................................................................
940
941Tragen Sie neue Dateiendungen auch in {fileopenfilter_conf} ein,
942damit diese im GUI-Dateiauswahldialog als Filter angezeigt werden.
943
944
945=== PFADE DER KONFIG-DATEIEN
946
947Konfigurationsskripte werden in folgenden Verzeichnissen gesucht:
948
9491. `~/.highlight/`
9502. benutzerdefiniertes Verz., definiert mit `--data-dir`
9513. Wert der Umgebungsvariablen `HIGHLIGHT_DATADIR`
9524. `/usr/share/highlight/`
9535. `/etc/highlight/` (Pfad von `filetypes.conf` und `lsp.conf`)
9546. aktuelles Arbeitsverzeichnis (Fallback)
955
956Es wird erwartet, dass folgende Unterverzeichnisse die entsprechenden Skripte
957enthalten:
958
959* langDefs: `*.lang`
960* themes: `*.theme`
961* plugins: `*.lua`
962
963Eine eigene `filetypes.conf` kann direkt in in `~/.highlight/` gespeichert werden.
964
965Stelle die Suchpfade mit `--print-config` fest::
966+
967........................
968highlight --print-config
969........................
970
971== HIGHLIGHT EINBETTEN
972
973=== BEISPIELSKRIPTE
974
975Im {extras} Unterverzeichnis befinden sich Beispielskripte in PHP, Perl und
976Python, die highlight aufrufen und die Ausgabe als String auswerten. Diese
977Skripte koennen als Ausgangspunkt fuer neue Erweiterungen genutzt werden.
978
979=== PANDOC
980
981PP Makros und eine Anleitung dazu liegen in {extras_pandoc}.
982
983=== SWIG
984
985Eine SWIG Interface-Datei befindet sich in {extras_swig}.
986Installationshinweise stehen in {README_SWIG}, Beispiele sind in Perl, PHP und
987Python vorhanden.
988
989=== TCL
990
991Eine TCL-Erweiterung befindet sich in {extras_tcl}.
992Installationshinweise stehen in {README_TCL}.
993
994
995== KOMPILIEREN UND INSTALLIEREN
996
997=== VORKOMPILIERTE PAKETE
998
999In {INSTALL} befinden sich Informationen zur Kompilation und zu verfuegbaren
1000Installationspaketen.
1001
1002
1003=== KOMPILIER-ABHAENGIGKEITEN
1004
1005Highlight kompiliert zumindest mit gcc und clang. Zum Kompilieren sind Boost
1006
1007Header-Pakete und Lua5.x/LuaJit Development-Pakete noetig.
1008
1009Die optionale GUI benoetigt Qt5 Development-Pakete.
1010
1011Im {makefile} finden Sie weitere Informationen.
1012
1013
1014== ENTWICKLERKONTAKT
1015
1016Andre Simon
1017
1018a.simon@mailbox.org
1019
1020{andre-simon_de}
1021
1022Git Projekt mit Repository, Bugtracker:
1023
1024* https://gitlab.com/saalen/highlight/
1025
1026// EOF //
1027

README_LANGLIST.adoc

1= HIGHLIGHT LANGUAGES LIST
2André Simon
3v3.59, October 2020
4:lang: en
5:experimental:
6:icons: font
7:linkattrs:
8:toc!:
9// GitHub Settings for Admonitions Icons:
10ifdef::env-github[]
11:caution-caption: :fire:
12:important-caption: :heavy_exclamation_mark:
13:note-caption: :information_source:
14:tip-caption: :bulb:
15:warning-caption: :warning:
16endif::[]
17
18////
19*****************************************
20* THIS IS AN AUTO-GENERATED DOCUMENT!!! *
21*****************************************
22Any manual changes to this document will be
23overwritten by automated scripted updates!
24////
25
26// =====================================
27// Custom Attributes for Reference Links
28// =====================================
29:README: pass:q[link:README.adoc[`README`]]
30:filetypes_conf: pass:q[link:filetypes.conf[`filetypes.conf`^]]
31:script: pass:q[link:highlight-langs2md.sh[script^,title="View source of 'highlight-langs2md.sh' script"]]
32
33The table below lists all supported languages, their syntax definition filenames,
34and the associated file extensions (configured in {filetypes_conf}).
35
36By default, the `*.lang` files are located in `/usr/share/highlight/langDefs/`.
37See the {README} for other user defined locations.
38
39# Languages List
40
41Packaged language definitions, obtained via `highlight --list-scripts=langs`
42
43[cols="<4d,<1m,<5m"]
44|==========================================
45| Language | Filename | Extensions
46
47| ABAP/4                         | link:./langDefs/abap4.lang[`abap4.lang`,title="View source file"] |  abp
48| ABC                            | link:./langDefs/abc.lang[`abc.lang`,title="View source file"] |
49| Abstract                       | link:./langDefs/aspect.lang[`aspect.lang`,title="View source file"] |  was wud
50| ActionScript                   | link:./langDefs/actionscript.lang[`actionscript.lang`,title="View source file"] |  as
51| Active Server Pages            | link:./langDefs/asp.lang[`asp.lang`,title="View source file"] |  ascx ashx aspx
52| ADA95                          | link:./langDefs/ada.lang[`ada.lang`,title="View source file"] |  a adb ads gnad
53| Advanced Backus-Naur Form      | link:./langDefs/abnf.lang[`abnf.lang`,title="View source file"] |
54| Agda                           | link:./langDefs/agda.lang[`agda.lang`,title="View source file"] |
55| ALAN Interactive Fiction Language | link:./langDefs/alan.lang[`alan.lang`,title="View source file"] |  alan i
56| ALGOL 68                       | link:./langDefs/algol.lang[`algol.lang`,title="View source file"] |  alg
57| AMPL                           | link:./langDefs/ampl.lang[`ampl.lang`,title="View source file"] |  dat run
58| AMTrix                         | link:./langDefs/amtrix.lang[`amtrix.lang`,title="View source file"] |  hnd s4 s4h s4t t4
59| Ansible YAML                   | link:./langDefs/yaml.lang[`yaml.lang`,title="View source file"] |  yml
60| Apache Config                  | link:./langDefs/httpd.lang[`httpd.lang`,title="View source file"] |
61| AppleScript                    | link:./langDefs/applescript.lang[`applescript.lang`,title="View source file"] |
62| Applied Type System            | link:./langDefs/ats.lang[`ats.lang`,title="View source file"] |  dats
63| Arc                            | link:./langDefs/arc.lang[`arc.lang`,title="View source file"] |
64| ARM                            | link:./langDefs/arm.lang[`arm.lang`,title="View source file"] |
65| AS/400 CL                      | link:./langDefs/as400cl.lang[`as400cl.lang`,title="View source file"] |
66| ASCEND                         | link:./langDefs/ascend.lang[`ascend.lang`,title="View source file"] |  a4c
67| AsciiDoc                       | link:./langDefs/asciidoc.lang[`asciidoc.lang`,title="View source file"] |
68| AutoHotKey                     | link:./langDefs/autohotkey.lang[`autohotkey.lang`,title="View source file"] |  ahk
69| AutoIt                         | link:./langDefs/autoit.lang[`autoit.lang`,title="View source file"] |  au3
70| Avenue                         | link:./langDefs/avenue.lang[`avenue.lang`,title="View source file"] |
71| Backus-Naur Form               | link:./langDefs/bnf.lang[`bnf.lang`,title="View source file"] |
72| Ballerina                      | link:./langDefs/ballerina.lang[`ballerina.lang`,title="View source file"] |  bal
73| Bash                           | link:./langDefs/sh.lang[`sh.lang`,title="View source file"] |  bash ebuild eclass zsh
74| BBcode                         | link:./langDefs/bbcode.lang[`bbcode.lang`,title="View source file"] |
75| BCPL                           | link:./langDefs/bcpl.lang[`bcpl.lang`,title="View source file"] |
76| BibTeX                         | link:./langDefs/bibtex.lang[`bibtex.lang`,title="View source file"] |  bib
77| Biferno                        | link:./langDefs/biferno.lang[`biferno.lang`,title="View source file"] |  bfr
78| Bison                          | link:./langDefs/bison.lang[`bison.lang`,title="View source file"] |  y
79| Blitz Basic                    | link:./langDefs/blitzbasic.lang[`blitzbasic.lang`,title="View source file"] |  bb
80| BM Script                      | link:./langDefs/bms.lang[`bms.lang`,title="View source file"] |
81| Boo                            | link:./langDefs/boo.lang[`boo.lang`,title="View source file"] |
82| C and C++                      | link:./langDefs/c.lang[`c.lang`,title="View source file"] |  c++ cc cpp cu cxx h hh hpp hxx inl ipp
83| Ceylon                         | link:./langDefs/ceylon.lang[`ceylon.lang`,title="View source file"] |
84| Chapel                         | link:./langDefs/chpl.lang[`chpl.lang`,title="View source file"] |
85| Charmm                         | link:./langDefs/charmm.lang[`charmm.lang`,title="View source file"] |  inp
86| CHILL                          | link:./langDefs/chill.lang[`chill.lang`,title="View source file"] |  chl
87| Clean                          | link:./langDefs/clean.lang[`clean.lang`,title="View source file"] |  icl
88| ClearBasic                     | link:./langDefs/clearbasic.lang[`clearbasic.lang`,title="View source file"] |  cb
89| C#                             | link:./langDefs/csharp.lang[`csharp.lang`,title="View source file"] |  cs
90| Clipper                        | link:./langDefs/clipper.lang[`clipper.lang`,title="View source file"] |
91| Clips                          | link:./langDefs/clp.lang[`clp.lang`,title="View source file"] |
92| Clojure                        | link:./langDefs/clojure.lang[`clojure.lang`,title="View source file"] |  clj cljc cljs edn
93| CMake                          | link:./langDefs/cmake.lang[`cmake.lang`,title="View source file"] |
94| COBOL                          | link:./langDefs/cobol.lang[`cobol.lang`,title="View source file"] |  cbl cob
95| Coffeescript Block Regex       | link:./langDefs/cs_block_regex.lang[`cs_block_regex.lang`,title="View source file"] |
96| Coffeescript                   | link:./langDefs/coffee.lang[`coffee.lang`,title="View source file"] |
97| ColdFusion MX                  | link:./langDefs/coldfusion.lang[`coldfusion.lang`,title="View source file"] |  cfc cfm
98| Crack                          | link:./langDefs/crk.lang[`crk.lang`,title="View source file"] |
99| Crystal                        | link:./langDefs/crystal.lang[`crystal.lang`,title="View source file"] |  cr
100| CSS                            | link:./langDefs/css.lang[`css.lang`,title="View source file"] |
101| Dart                           | link:./langDefs/dart.lang[`dart.lang`,title="View source file"] |
102| delphi                         | link:./langDefs/delphi.lang[`delphi.lang`,title="View source file"] |  dpr pas
103| Device Tree Source             | link:./langDefs/dts.lang[`dts.lang`,title="View source file"] |  dtsi
104| Diff                           | link:./langDefs/diff.lang[`diff.lang`,title="View source file"] |  patch
105| D                              | link:./langDefs/d.lang[`d.lang`,title="View source file"] |
106| Dockerfile                     | link:./langDefs/docker.lang[`docker.lang`,title="View source file"] |  dockerfile
107| Dylan                          | link:./langDefs/dylan.lang[`dylan.lang`,title="View source file"] |
108| EBNF2                          | link:./langDefs/ebnf2.lang[`ebnf2.lang`,title="View source file"] |
109| Eiffel                         | link:./langDefs/eiffel.lang[`eiffel.lang`,title="View source file"] |  e se
110| Elixir                         | link:./langDefs/elixir.lang[`elixir.lang`,title="View source file"] |  ex exs
111| E-Mail treated as Markup       | link:./langDefs/email.lang[`email.lang`,title="View source file"] |
112| ERB Templates                  | link:./langDefs/erb.lang[`erb.lang`,title="View source file"] |
113| Erlang                         | link:./langDefs/erlang.lang[`erlang.lang`,title="View source file"] |  erl hrl
114| Euphoria                       | link:./langDefs/euphoria.lang[`euphoria.lang`,title="View source file"] |  eu ew exw wxu
115| EXAPUNKS                       | link:./langDefs/exapunks.lang[`exapunks.lang`,title="View source file"] |  exa exapunks
116| Excel Formulas                 | link:./langDefs/excel.lang[`excel.lang`,title="View source file"] |
117| Express                        | link:./langDefs/express.lang[`express.lang`,title="View source file"] |  exp
118| Extended Backus-Naur Form      | link:./langDefs/ebnf.lang[`ebnf.lang`,title="View source file"] |
119| FAME                           | link:./langDefs/fame.lang[`fame.lang`,title="View source file"] |  fame
120| fasm                           | link:./langDefs/fasm.lang[`fasm.lang`,title="View source file"] |  inc
121| Felix                          | link:./langDefs/felix.lang[`felix.lang`,title="View source file"] |  flx
122| Fish                           | link:./langDefs/fish.lang[`fish.lang`,title="View source file"] |
123| F#                             | link:./langDefs/fsharp.lang[`fsharp.lang`,title="View source file"] |  fs fsi fsx
124| Fortran 77                     | link:./langDefs/fortran77.lang[`fortran77.lang`,title="View source file"] |  f for ftn
125| Fortran 90                     | link:./langDefs/fortran90.lang[`fortran90.lang`,title="View source file"] |  f90 f95
126| Frink                          | link:./langDefs/frink.lang[`frink.lang`,title="View source file"] |
127| fstab config file              | link:./langDefs/fstab.lang[`fstab.lang`,title="View source file"] |
128| Gambas                         | link:./langDefs/gambas.lang[`gambas.lang`,title="View source file"] |  class
129| (G)AWK                         | link:./langDefs/awk.lang[`awk.lang`,title="View source file"] |
130| gdb                            | link:./langDefs/gdb.lang[`gdb.lang`,title="View source file"] |
131| GDScript                       | link:./langDefs/gdscript.lang[`gdscript.lang`,title="View source file"] |  gd
132| Generic Assembler              | link:./langDefs/assembler.lang[`assembler.lang`,title="View source file"] |  29k 68s 68x a51 asm x86
133| Generic config files           | link:./langDefs/conf.lang[`conf.lang`,title="View source file"] |  anacrontab
134| GitHub Flavored Markdown       | link:./langDefs/markdown.lang[`markdown.lang`,title="View source file"] |  markdown md
135| GitHub Flavored Markdown       | link:./langDefs/md.lang[`md.lang`,title="View source file"] |
136| Go                             | link:./langDefs/go.lang[`go.lang`,title="View source file"] |
137| Graphviz                       | link:./langDefs/graphviz.lang[`graphviz.lang`,title="View source file"] |  dot
138| Haml (HTML Abstraction Markup Language) | link:./langDefs/haml.lang[`haml.lang`,title="View source file"] |
139| Haskell LHS                    | link:./langDefs/lhs.lang[`lhs.lang`,title="View source file"] |
140| Haskell                        | link:./langDefs/haskell.lang[`haskell.lang`,title="View source file"] |  hs
141| haXe                           | link:./langDefs/haxe.lang[`haxe.lang`,title="View source file"] |  hx
142| Hecl                           | link:./langDefs/hcl.lang[`hcl.lang`,title="View source file"] |
143| HTML                           | link:./langDefs/html.lang[`html.lang`,title="View source file"] |  htm jinja twig xhtml
144| Hugo                           | link:./langDefs/hugo.lang[`hugo.lang`,title="View source file"] |  hug
145| Icon                           | link:./langDefs/icon.lang[`icon.lang`,title="View source file"] |  icn
146| IDL                            | link:./langDefs/idl.lang[`idl.lang`,title="View source file"] |
147| Informix                       | link:./langDefs/informix.lang[`informix.lang`,title="View source file"] |  4gl
148| INI                            | link:./langDefs/ini.lang[`ini.lang`,title="View source file"] |  cfg desktop doxyfile inf kdev3 reg
149| Inno Setup                     | link:./langDefs/innosetup.lang[`innosetup.lang`,title="View source file"] |  iss
150| Interactive Data Language      | link:./langDefs/idlang.lang[`idlang.lang`,title="View source file"] |
151| INTERLIS                       | link:./langDefs/interlis.lang[`interlis.lang`,title="View source file"] |  ili
152| IO                             | link:./langDefs/io.lang[`io.lang`,title="View source file"] |
153| Jasmin                         | link:./langDefs/jasmin.lang[`jasmin.lang`,title="View source file"] |  j
154| Java FX                        | link:./langDefs/fx.lang[`fx.lang`,title="View source file"] |
155| Java                           | link:./langDefs/java.lang[`java.lang`,title="View source file"] |  gradle groovy grv jenkinsfile
156| Javascript                     | link:./langDefs/js.lang[`js.lang`,title="View source file"] |
157| Javascript Regex               | link:./langDefs/js_regex.lang[`js_regex.lang`,title="View source file"] |
158| JavaServer Pages               | link:./langDefs/jsp.lang[`jsp.lang`,title="View source file"] |
159| JSON                           | link:./langDefs/json.lang[`json.lang`,title="View source file"] |
160| JSX                            | link:./langDefs/jsx.lang[`jsx.lang`,title="View source file"] |
161| Julia                          | link:./langDefs/julia.lang[`julia.lang`,title="View source file"] |  jl
162| Kotlin                         | link:./langDefs/kotlin.lang[`kotlin.lang`,title="View source file"] |  kt kts
163| LDAP                           | link:./langDefs/ldif.lang[`ldif.lang`,title="View source file"] |
164| LESS                           | link:./langDefs/less.lang[`less.lang`,title="View source file"] |
165| Lilypond                       | link:./langDefs/lilypond.lang[`lilypond.lang`,title="View source file"] |  ly
166| Limbo                          | link:./langDefs/limbo.lang[`limbo.lang`,title="View source file"] |  b
167| Linden Script                  | link:./langDefs/lindenscript.lang[`lindenscript.lang`,title="View source file"] |  lsl
168| Lisp                           | link:./langDefs/lisp.lang[`lisp.lang`,title="View source file"] |  cl clisp el fas fasl lsp mud sbcl scm scom
169| Logtalk                        | link:./langDefs/logtalk.lang[`logtalk.lang`,title="View source file"] |  lgt
170| Lotos                          | link:./langDefs/lotos.lang[`lotos.lang`,title="View source file"] |
171| Lotus                          | link:./langDefs/lotus.lang[`lotus.lang`,title="View source file"] |  ls
172| Lua (for LuaTeX)               | link:./langDefs/inc_luatex.lang[`inc_luatex.lang`,title="View source file"] |
173| Lua                            | link:./langDefs/lua.lang[`lua.lang`,title="View source file"] |
174| Luban                          | link:./langDefs/luban.lang[`luban.lang`,title="View source file"] |  lbn
175| Magic eXtensible Markup        | link:./langDefs/mxml.lang[`mxml.lang`,title="View source file"] |
176| Make                           | link:./langDefs/make.lang[`make.lang`,title="View source file"] |  gnumakefile mak makefile mk
177| Maple                          | link:./langDefs/maple.lang[`maple.lang`,title="View source file"] |  mpl
178| Matlab                         | link:./langDefs/matlab.lang[`matlab.lang`,title="View source file"] |  m
179| MaxScript                      | link:./langDefs/ms.lang[`ms.lang`,title="View source file"] |
180| Maya                           | link:./langDefs/maya.lang[`maya.lang`,title="View source file"] |  mel
181| Mercury                        | link:./langDefs/mercury.lang[`mercury.lang`,title="View source file"] |
182| Meson                          | link:./langDefs/meson.lang[`meson.lang`,title="View source file"] |
183| Microsoft PowerShell           | link:./langDefs/ps1.lang[`ps1.lang`,title="View source file"] |  psd1 psm1
184| Miranda                        | link:./langDefs/miranda.lang[`miranda.lang`,title="View source file"] |
185| mIRC Scripting                 | link:./langDefs/msl.lang[`msl.lang`,title="View source file"] |  nbs
186| Modelica                       | link:./langDefs/modelica.lang[`modelica.lang`,title="View source file"] |  mo
187| Modula2                        | link:./langDefs/mod2.lang[`mod2.lang`,title="View source file"] |  def mod
188| Modula3                        | link:./langDefs/mod3.lang[`mod3.lang`,title="View source file"] |  i3 m3
189| MoonScript                     | link:./langDefs/moon.lang[`moon.lang`,title="View source file"] |
190| MS DOS Batch                   | link:./langDefs/bat.lang[`bat.lang`,title="View source file"] |  cmd
191| MSSQL                          | link:./langDefs/mssql.lang[`mssql.lang`,title="View source file"] |
192| Nasal                          | link:./langDefs/nasal.lang[`nasal.lang`,title="View source file"] |  nas
193| Nemerle                        | link:./langDefs/nemerle.lang[`nemerle.lang`,title="View source file"] |  n
194| NetRexx                        | link:./langDefs/netrexx.lang[`netrexx.lang`,title="View source file"] |  nrx
195| NeXT Byte Codes                | link:./langDefs/nbc.lang[`nbc.lang`,title="View source file"] |
196| Nginx configuration            | link:./langDefs/nginx.lang[`nginx.lang`,title="View source file"] |
197| Nice                           | link:./langDefs/nice.lang[`nice.lang`,title="View source file"] |
198| Nim                            | link:./langDefs/nim.lang[`nim.lang`,title="View source file"] |
199| Notation3 (N3), N-Triples, Turtle, SPARQL | link:./langDefs/n3.lang[`n3.lang`,title="View source file"] |  nt ttl
200| Not eXactly C                  | link:./langDefs/nxc.lang[`nxc.lang`,title="View source file"] |
201| NSIS                           | link:./langDefs/nsis.lang[`nsis.lang`,title="View source file"] |  nsh nsi
202| Oberon                         | link:./langDefs/oberon.lang[`oberon.lang`,title="View source file"] |  ooc
203| Objective Caml                 | link:./langDefs/ocaml.lang[`ocaml.lang`,title="View source file"] |  ml mli
204| Objective C                    | link:./langDefs/objc.lang[`objc.lang`,title="View source file"] |
205| Object Script                  | link:./langDefs/os.lang[`os.lang`,title="View source file"] |
206| Octave                         | link:./langDefs/octave.lang[`octave.lang`,title="View source file"] |
207| OpenObjectRexx                 | link:./langDefs/oorexx.lang[`oorexx.lang`,title="View source file"] |
208| OpenSCAD                       | link:./langDefs/scad.lang[`scad.lang`,title="View source file"] |
209| Oz                             | link:./langDefs/oz.lang[`oz.lang`,title="View source file"] |
210| Paradox                        | link:./langDefs/paradox.lang[`paradox.lang`,title="View source file"] |  sc
211| Pascal                         | link:./langDefs/pas.lang[`pas.lang`,title="View source file"] |
212| PATROL                         | link:./langDefs/psl.lang[`psl.lang`,title="View source file"] |
213| Perl                           | link:./langDefs/perl.lang[`perl.lang`,title="View source file"] |  cgi perl pl plex plx pm
214| PHP                            | link:./langDefs/php.lang[`php.lang`,title="View source file"] |  php3 php4 php5 php6 php7 phps phpt
215| Pike                           | link:./langDefs/pike.lang[`pike.lang`,title="View source file"] |  pmod
216| PL/1                           | link:./langDefs/pl1.lang[`pl1.lang`,title="View source file"] |  bdy ff fp fpp rpp sf sp spb spe spp sps wf wp wpb wpp wps
217| Plain text                     | link:./langDefs/txt.lang[`txt.lang`,title="View source file"] |  text
218| PL/Perl                        | link:./langDefs/plperl.lang[`plperl.lang`,title="View source file"] |
219| PL/Python                      | link:./langDefs/plpython.lang[`plpython.lang`,title="View source file"] |
220| PL/SQL                         | link:./langDefs/sql.lang[`sql.lang`,title="View source file"] |
221| PL/Tcl                         | link:./langDefs/pltcl.lang[`pltcl.lang`,title="View source file"] |
222| Polygen                        | link:./langDefs/polygen.lang[`polygen.lang`,title="View source file"] |  grm
223| Pony                           | link:./langDefs/pony.lang[`pony.lang`,title="View source file"] |
224| Portable Document Format       | link:./langDefs/pdf.lang[`pdf.lang`,title="View source file"] |
225| PostScript                     | link:./langDefs/ps.lang[`ps.lang`,title="View source file"] |
226| PO translation                 | link:./langDefs/po.lang[`po.lang`,title="View source file"] |
227| POV-Ray                        | link:./langDefs/pov.lang[`pov.lang`,title="View source file"] |
228| PowerPC Assembler              | link:./langDefs/s.lang[`s.lang`,title="View source file"] |
229| Progress                       | link:./langDefs/progress.lang[`progress.lang`,title="View source file"] |  p w
230| Prolog                         | link:./langDefs/pro.lang[`pro.lang`,title="View source file"] |  pro
231| PureBASIC                      | link:./langDefs/purebasic.lang[`purebasic.lang`,title="View source file"] |  pb pbf pbi
232| Pure                           | link:./langDefs/pure.lang[`pure.lang`,title="View source file"] |
233| Pyrex                          | link:./langDefs/pyrex.lang[`pyrex.lang`,title="View source file"] |  pyx
234| Python                         | link:./langDefs/python.lang[`python.lang`,title="View source file"] |  cpy gyp gypi pxd pxi py py3 pyi pyw rpy sconstruct snakefile wscript
235| QMake Project                  | link:./langDefs/qmake.lang[`qmake.lang`,title="View source file"] |
236| QML                            | link:./langDefs/qml.lang[`qml.lang`,title="View source file"] |
237| Qore                           | link:./langDefs/q.lang[`q.lang`,title="View source file"] |
238| Qu                             | link:./langDefs/qu.lang[`qu.lang`,title="View source file"] |
239| Rebol                          | link:./langDefs/rebol.lang[`rebol.lang`,title="View source file"] |
240| Relax NG                       | link:./langDefs/rnc.lang[`rnc.lang`,title="View source file"] |
241| reStructured Text              | link:./langDefs/rst.lang[`rst.lang`,title="View source file"] |
242| Rexx                           | link:./langDefs/rexx.lang[`rexx.lang`,title="View source file"] |  rex rx the
243| R                              | link:./langDefs/r.lang[`r.lang`,title="View source file"] |
244| RPG                            | link:./langDefs/rpg.lang[`rpg.lang`,title="View source file"] |
245| RPL Programming Language       | link:./langDefs/rpl.lang[`rpl.lang`,title="View source file"] |
246| RPM Spec                       | link:./langDefs/spec.lang[`spec.lang`,title="View source file"] |
247| Ruby                           | link:./langDefs/ruby.lang[`ruby.lang`,title="View source file"] |  appfile appraisals berksfile brewfile capfile cheffile config.ru deliverfile fastfile fcgi gemfile gemspec guardfile irbrc jbuilder podfile podspec pp prawn rabl rake rakefile rantfile rb rbx rjs ruby scanfile simplecov snapfile thor thorfile vagrantfile
248| Rust                           | link:./langDefs/rs.lang[`rs.lang`,title="View source file"] |
249| SAS                            | link:./langDefs/sas.lang[`sas.lang`,title="View source file"] |
250| SASS/SCSS                      | link:./langDefs/scss.lang[`scss.lang`,title="View source file"] |
251| Scala                          | link:./langDefs/scala.lang[`scala.lang`,title="View source file"] |
252| Scilab                         | link:./langDefs/scilab.lang[`scilab.lang`,title="View source file"] |  sce sci
253| Sequence Alignment Map (use with sam_seq.lua plug-in) | link:./langDefs/sam.lang[`sam.lang`,title="View source file"] |
254| Slim (experimental)            | link:./langDefs/slim.lang[`slim.lang`,title="View source file"] |
255| SMALL                          | link:./langDefs/small.lang[`small.lang`,title="View source file"] |  sma
256| Smalltalk                      | link:./langDefs/smalltalk.lang[`smalltalk.lang`,title="View source file"] |  gst sq st
257| SNMP                           | link:./langDefs/snmp.lang[`snmp.lang`,title="View source file"] |  mib smi
258| SNOBOL                         | link:./langDefs/snobol.lang[`snobol.lang`,title="View source file"] |  sno
259| Solidity                       | link:./langDefs/solidity.lang[`solidity.lang`,title="View source file"] |  sol
260| SPIN SQL                       | link:./langDefs/spn.lang[`spn.lang`,title="View source file"] |
261| Squirrel                       | link:./langDefs/squirrel.lang[`squirrel.lang`,title="View source file"] |  nut
262| Standard ML                    | link:./langDefs/sml.lang[`sml.lang`,title="View source file"] |
263| Stylus                         | link:./langDefs/styl.lang[`styl.lang`,title="View source file"] |
264| SuperX++                       | link:./langDefs/xpp.lang[`xpp.lang`,title="View source file"] |
265| SVG                            | link:./langDefs/svg.lang[`svg.lang`,title="View source file"] |
266| Swift                          | link:./langDefs/swift.lang[`swift.lang`,title="View source file"] |
267| Sybase SQL                     | link:./langDefs/sybase.lang[`sybase.lang`,title="View source file"] |
268| Tcl/Tk                         | link:./langDefs/tcl.lang[`tcl.lang`,title="View source file"] |  itcl wish
269| TCSH                           | link:./langDefs/tcsh.lang[`tcsh.lang`,title="View source file"] |
270| Terraform                      | link:./langDefs/terraform.lang[`terraform.lang`,title="View source file"] |
271| TeX and LaTeX                  | link:./langDefs/tex.lang[`tex.lang`,title="View source file"] |  cls sty
272| TOML                           | link:./langDefs/toml.lang[`toml.lang`,title="View source file"] |
273| Transact-SQL                   | link:./langDefs/tsql.lang[`tsql.lang`,title="View source file"] |
274| TSX (TypeScript with React)    | link:./langDefs/tsx.lang[`tsx.lang`,title="View source file"] |
275| TTCN3                          | link:./langDefs/ttcn3.lang[`ttcn3.lang`,title="View source file"] |
276| TypeScript                     | link:./langDefs/ts.lang[`ts.lang`,title="View source file"] |
277| UPC (and C, technically)       | link:./langDefs/upc.lang[`upc.lang`,title="View source file"] |
278| Vala                           | link:./langDefs/vala.lang[`vala.lang`,title="View source file"] |
279| Verilog                        | link:./langDefs/verilog.lang[`verilog.lang`,title="View source file"] |  v
280| VHDL                           | link:./langDefs/vhd.lang[`vhd.lang`,title="View source file"] |
281| vimscript                      | link:./langDefs/vimscript.lang[`vimscript.lang`,title="View source file"] |  gvimrc vim vimrc
282| Visual Basic                   | link:./langDefs/vb.lang[`vb.lang`,title="View source file"] |  bas basic bi vbs
283| vue.js (beta)                  | link:./langDefs/vue.lang[`vue.lang`,title="View source file"] |
284| Web Assembly Text              | link:./langDefs/wat.lang[`wat.lang`,title="View source file"] |
285| Whiley                         | link:./langDefs/whiley.lang[`whiley.lang`,title="View source file"] |
286| Wren                           | link:./langDefs/wren.lang[`wren.lang`,title="View source file"] |
287| XML                            | link:./langDefs/xml.lang[`xml.lang`,title="View source file"] |  csproj dtd ecf ent glade hdr hub jnlp nrm opml resx rss sgm sgml tld vxml wml xsd xsl
288| Yaiff                          | link:./langDefs/yaiff.lang[`yaiff.lang`,title="View source file"] |
289| Yang                           | link:./langDefs/yang.lang[`yang.lang`,title="View source file"] |
290| Zonnon                         | link:./langDefs/znn.lang[`znn.lang`,title="View source file"] |
291|==========================================
292
293[NOTE]
294This page is autogenerated via a {script}.
295Any manual edits to the page will be lost when the page is updated.
296
297
298

README_LSP_CLIENT.adoc

1= HIGHLIGHT LANGUAGE SERVER PROTOCOL CLIENT
2André Simon
3:revdate: February 2021
4:lang: en
5:toc: left
6:toc-title: Contents
7:toclevels: 4
8:sectnums:
9:sectnumlevels: 2
10:sectanchors:
11// Misc Settings:
12:experimental: true
13:icons: font
14:linkattrs: true
15
16
17== LSP SUPPORT
18
19Starting with version 4.0, highlight will use the LSP protocol to enhance
20its output.
21
22What does this mean?
23
24Many editors make use of "Language Servers" to get syntax information of various
25programming languages without the need to implement a deep understanding of the
26files'' syntax they process. Well known code editors with LSP support are VSCode,
27Kate, vim, Emacs and Eclipse.
28
29More information about LSP and editor support:
30https://langserver.org/
31
32Highlight''s LSP based features:
33
34* enhanced tooltips using hover requests
35* semantic highlighting
36* syntax error highlighting
37
38
39== PROFILES
40
41Language servers are configured in lsp.conf:
42
43+
44..........................................................................
45
46Servers = {
47
48  { Server="clangd", Exec="clangd", Syntax="c", Options={"--log=error"} },
49  { Server="ccls", Exec="ccls", Syntax="c", Options={"-v=-3", "--"} },
50  { Server="ccls-objc", Exec="ccls", Syntax="objc", Options={"-v=-3", "--"} },
51
52  { Server="gopls", Exec="gopls", Syntax="go", Options={} },
53
54  { Server="rls", Exec="rls", Syntax="rust", Options={} },
55  { Server="rust-analyzer", Exec="rust-analyzer", Syntax="rust", Delay=250, Options={} },
56
57  { Server="pyls", Exec="pyls", Syntax="python", Options={"--check-parent-process"} },
58
59  { Server="R", Exec="R", Syntax="r", Options={"--slave", "-e", "languageserver::run()"} },
60
61  { Server="clangd-win", Exec="F:\\LLVM\\bin\\clangd.exe", Syntax="c", Options={"--log=error"} },
62
63}
64..........................................................................
65
66These profile settings may also be set with corresponding `--ls-*` options.
67
68
69== OPTIONS
70
71Command line options:
72+
73..........................................................................
74Language Server options:
75
76     --ls-profile=<server>      read LSP configuration from lsp.conf
77     --ls-delay=<ms>            set server initialization delay
78     --ls-exec=<bin>            set server executable name
79     --ls-option=<option>       set server CLI option (can be repeated)
80     --ls-hover                 execute hover requests (HTML output only)
81     --ls-semantic              retrieve semantic token types (requires LSP 3.16)
82     --ls-syntax=<lang>         set syntax which is understood by the server
83     --ls-syntax-error          retrieve syntax error information
84                                  (assumes --ls-hover or --ls-semantic)
85     --ls-workspace=<dir>       set workspace directory to init. the server
86..........................................................................
87
88The GUI offers an LSP tab to enable these options.
89
90Important: LSP features require absolute input file paths.
91
92== THEMES
93
94Colour themes have a new section to define semantic token styles. These
95types use the same identifiers which are reported by the language server
96capabilities. If the server reports token types not listed here, they
97will be ignored.
98
99+
100..........................................................................
101-- new LSP based elements:
102
103SemanticTokenTypes  = {
104  { Type = 'type', Style = Keywords[2] },
105  { Type = 'class', Style =  Keywords[1] },
106  { Type = 'struct', Style =  Keywords[4] },
107  { Type = 'interface', Style = Keywords[1] },
108  { Type = 'parameter', Style = Keywords[5] },
109  { Type = 'variable', Style = Keywords[6] },
110  { Type = 'enumMember', Style = Keywords[6] },
111  { Type = 'function', Style = Keywords[3] },
112  { Type = 'method', Style = Keywords[3] },
113  { Type = 'keyword', Style =  Keywords[1]},
114  { Type = 'number', Style = Number },
115  { Type = 'regexp', Style = String },
116  { Type = 'operator', Style = Operator },
117}
118
119-- Error token (default: red color)
120Error = { Custom = { { Format = "html", Style = "color: green" } } }
121
122-- Error message (default: color:red; border:solid 1px red;)
123ErrorMessage = { Custom = { { Format = "html", Style = "color: green" } } }
124
125-- Hover tooltip span (default: cursor:help )
126Hover = { Custom = { { Format = "html", Style = "cursor:help" } } }
127
128..........................................................................
129
130Additional elements to describe token modifiers will be added in a later release.
131
132
133=== EXAMPLE INVOCATION
134+
135..........................................................................
136
137highlight  -I --ls-profile ccls --ls-workspace '/home/andre/Projekte/c' /home/andre/Projekte/c/re.cpp --out-format html  --ls-hover > /home/andre/Projekte/c/re.cpp.ccls.html
138
139highlight  -I  --ls-profile rust-analyzer --ls-workspace '/home/andre/Projekte/rust/fibo'  /home/andre/Projekte/rust/fibo/src/main.rs  --out-format html --ls-semantic > fibo.html
140..........................................................................
141
142
143=== DEBUGGING
144
145Apply `-v -v` to print LSP messages.
146
147
148// EOF //
149

README_PLUGINS.adoc

1= HIGHLIGHT PLUGIN MANUAL
2André Simon
3v3.59, October 2020
4:lang: en
5:toc: left
6:toc-title: Contents
7:toclevels: 4
8:sectnums:
9:sectnumlevels: 2
10:sectanchors:
11// Cross References:
12:xrefstyle: short
13:section-refsig: Sect.
14// Misc Settings:
15:experimental: true
16:icons: font
17:linkattrs: true
18// GitHub Settings to enable Admonitions Icons in preview:
19ifdef::env-github[]
20:caution-caption: :fire:
21:important-caption: :heavy_exclamation_mark:
22:note-caption: :information_source:
23:tip-caption: :bulb:
24:warning-caption: :warning:
25endif::[]
26
27// =====================================
28// Custom Attributes for Reference Links
29// =====================================
30// Folders:
31:plugins: pass:q[link:plugins/[`plugins/`^]]
32// Plugins files:
33:bash_functions_lua: pass:q[link:plugins/bash_functions.lua[`bash_functions.lua`^]]
34:cpp_ref_cplusplus_com_lua: pass:q[link:plugins/cpp_ref_cplusplus_com.lua[`cpp_ref_cplusplus_com.lua`^]]
35:ctags_html_tooltips_lua: pass:q[link:plugins/ctags_html_tooltips.lua[`ctags_html_tooltips.lua`^]]
36:outhtml_codefold_lua: pass:q[link:plugins/outhtml_codefold.lua[`outhtml_codefold.lua`^]]
37:outhtml_curly_brackets_matcher_lua: pass:q[link:plugins/outhtml_curly_brackets_matcher.lua[`outhtml_curly_brackets_matcher.lua`^]]
38:outhtml_keyword_matcher_lua: pass:q[link:plugins/outhtml_keyword_matcher.lua[`outhtml_keyword_matcher.lua`^]]
39:outhtml_keyword_matcher_lua: pass:q[link:plugins/outhtml_keyword_matcher.lua[`outhtml_keyword_matcher.lua`^]]
40:theme_invert_lua: pass:q[link:plugins/theme_invert.lua[`theme_invert.lua`^]]
41
42== ABOUT
43
44The plug-in interface allows modifications of syntax parsing, colouring and
45the document's header and footer.
46
47A common task would be to define a new set of syntax keywords, or to add items
48to existing keyword groups. More advanced plug-ins add tooltips based on ctags
49input or source code folding to the output (see <<EXAMPLES>>).
50
51
52== SCRIPT STRUCTURE
53
54The following script contains the basic plug-in structure which has no effect
55on the output:
56
57[source,lua]
58--------------------------------------------------------------------------------
59Description="Plugin Boilerplate"
60
61-- optional parameter desc: syntax description
62function syntaxUpdate(desc)
63end
64
65function themeUpdate(desc)
66end
67
68function formatUpdate(desc)
69end
70
71Plugins={
72  { Type="theme", Chunk=themeUpdate },
73  { Type="lang", Chunk=syntaxUpdate },
74  { Type="format", Chunk=formatUpdate },
75}
76--------------------------------------------------------------------------------
77
78The first line contains a description which gives a short summary of the
79plug-in effects.
80
81The next lines contain function definitions:
82
83* The `syntaxUpdate` function is applied on syntax definition scripts (`+*.lang+`),
84  whereas the `themeUpdate` function is applied on colour themes (`+*.theme+`).
85* The `formatUpdate` is not executed in a syntax or theme Lua state.
86  It just returns strings to override or enhance the document header and footer.
87* The `desc` parameter contains the description string of the loaded syntax
88  definition or colour theme. This information can be used to restrict
89  modifications to certain kinds of input (i.e. only C code should be
90  enhanced with syslog keywords).
91
92Finally the `Plugins` array connects the functions to the Lua states which
93are created when highlight loads a lang or theme script.
94In this example, `themeUpdate` is connected to the theme state, and `syntaxUpdate`
95to the lang state.
96It is not required to always define both connections if your plugin only affects
97one of the config script types.
98
99
100== SYNTAX CHUNK ELEMENTS
101
102The following list includes all variables and constants you may use to adjust
103the parser's syntax highlighting.
104
105Syntax definition items:
106
107[horizontal]
108`Comments`                :: table
109`Description`             :: string
110`Digits`                  :: string
111`EnableIndentation`       :: boolean
112`Identifiers`             :: string
113`IgnoreCase`              :: boolean
114`Keywords`                :: table
115`NestedSections`          :: table
116`Operators`               :: string
117`PreProcessor`            :: table
118`Strings`                 :: table
119
120
121Document modification items:
122
123[horizontal]
124`HeaderInjection`         :: string
125`FooterInjection`         :: string
126
127Read only (internal highlighting states):
128
129[horizontal]
130`HL_STANDARD`             :: number
131`HL_BLOCK_COMMENT`        :: number
132`HL_BLOCK_COMMENT_END`    :: number
133`HL_EMBEDDED_CODE_BEGIN`  :: number
134`HL_EMBEDDED_CODE_END`    :: number
135`HL_ESC_SEQ`              :: number
136`HL_ESC_SEQ_END`          :: number
137`HL_IDENTIFIER_BEGIN`     :: number
138`HL_IDENTIFIER_END`       :: number
139`HL_KEYWORD`              :: number
140`HL_KEYWORD_END`          :: number
141`HL_LINENUMBER`           :: number
142`HL_LINE_COMMENT`         :: number
143`HL_LINE_COMMENT_END`     :: number
144`HL_NUMBER`               :: number
145`HL_OPERATOR`             :: number
146`HL_OPERATOR_END`         :: number
147`HL_PREPROC`              :: number
148`HL_PREPROC_END`          :: number
149`HL_PREPROC_STRING`       :: number
150`HL_STRING`               :: number
151`HL_STRING_END`           :: number
152`HL_UNKNOWN`              :: number
153`HL_REJECT`               :: number
154
155Read only (output document format):
156
157[horizontal]
158`HL_OUTPUT`               :: number (selected format)
159`HL_FORMAT_HTML`          :: number
160`HL_FORMAT_XHTML`         :: number
161`HL_FORMAT_TEX`           :: number
162`HL_FORMAT_LATEX`         :: number
163`HL_FORMAT_RTF`           :: number
164`HL_FORMAT_ANSI`          :: number
165`HL_FORMAT_XTERM256`      :: number
166`HL_FORMAT_TRUECOLOR`     :: number
167`HL_FORMAT_SVG`           :: number
168`HL_FORMAT_BBCODE`        :: number
169`HL_FORMAT_PANGO`         :: number
170`HL_FORMAT_ODT`           :: number
171
172Read only (other):
173
174[horizontal]
175`HL_PLUGIN_PARAM`         :: string (set with `--plug-in-param`)
176`HL_LANG_DIR`             :: string (path of language definition directory)
177
178Functions:
179
180[horizontal]
181`AddKeyword`              :: function
182`RemoveKeyword`           :: function
183`OnStateChange`           :: function
184`Decorate`                :: function
185`DecorateLineBegin`       :: function
186`DecorateLineEnd`         :: function
187`StoreValue`              :: function
188
189[IMPORTANT]
190================================================================================
191Functions will only be executed if they are defined as local functions within the
192`lang` chunk referenced in the `Plugins` array.
193They will be ignored when defined elsewhere in the script.
194================================================================================
195
196The functions `AddKeyword`, `RemoveKeyword` and `OnStateChange` are also useful
197in language definitions without a plug-in use case.
198
199
200=== FUNCTIONS ADDKEYWORD/REMOVEKEYWORD
201
202[[AddKeyword]]
203The `AddKeyword` function will add a keyword to one of the the internal keyword
204lists. It has no effect if the keyword was added before.
205Keywords added with `AddKeyword` will remain active for all files of the same
206syntax if highlight is in batch mode.
207
208................................................................................
209AddKeyword(keyword, kwGroupID)
210
211  Parameters: keyword:   string which should be added to a keyword list
212              kwGroupID: keyword group ID of the keyword
213  Returns:    true if successful
214................................................................................
215
216[[RemoveKeyword]]
217The `RemoveKeyword` function erases the given keyword from the internal list.
218
219................................................................................
220RemoveKeyword(keyword)
221
222  Parameters: keyword:   string which should be removed from the keyword list
223  Returns:    true if successful
224................................................................................
225
226
227=== FUNCTION ADDPERSISTENTSTATE
228
229[[AddPersistentState]]
230This function enables storage of keywords and keyword ranges in a plug-in file.
231If the syntax contains elements which depend on a context, you can highlight
232them although this context is lost in other input files or code sections.
233The invocation of AddPersistentState will cause highlight to save a plugin as
234temporary file and parse input files using this plug-in again if necessary.
235
236................................................................................
237AddPersistentState(keyword, kwGroupID)
238
239  Parameters: keyword:   string which should be added to a keyword list
240              kwGroupID: keyword group ID of the keyword
241  Returns:    true if successful
242................................................................................
243
244................................................................................
245AddPersistentState(lineno, kwGroupID, column, length)
246
247  Parameters: lineno:    line number
248              kwGroupID: the keyword group ID
249              column:    column
250              length:    length of the keyword
251  Returns:    true if successful
252................................................................................
253
254
255=== FUNCTION ONSTATECHANGE
256
257[[OnStateChange]]
258This function is a hook which is called if an internal state changes (e.g. from
259`HL_STANDARD` to `HL_KEYWORD` if a keyword is found). It can be used to alter
260the new state or to manipulate syntax elements like keyword lists.
261
262................................................................................
263OnStateChange(oldState, newState, token, kwGroupID, lineno, column)
264
265  Hook Event: Highlighting parser state change
266  Parameters: oldState:  old state
267              newState:  intended new state
268              token:     the current token which triggered the new state
269              kwGroupID: if newState is HL_KEYWORD, the parameter
270                         contains the keyword group ID
271              lineno:    line number (since 3.50)
272              column:    line column (since 3.50)
273  Returns:    Correct state to continue OR HL_REJECT
274................................................................................
275
276Returns `HL_REJECT` if the recognized token and state should be discarded;
277the first character of token will be outputted and highlighted as `oldState`.
278
279
280Example for its usage in a plugin context:
281
282[source,lua]
283--------------------------------------------------------------------------------
284function OnStateChange(oldState, newState, token, kwgroup)
285   if newState==HL_KEYWORD and kwgroup==5 then
286      AddKeyword(token, 5)
287   end
288   return newState
289end
290--------------------------------------------------------------------------------
291
292This function adds the current keyword to the internal keyword list if the
293keyword belongs to keyword group 5. If keyword group 5 is defined by a regex,
294this token will be recognized later as a keyword even if the regular expression
295does no longer match.
296
297[IMPORTANT]
298================================================================================
299If both the syntax file and the plug-in script contain an `OnStateChange`
300function, the plug-in definition will replace the function of the syntax file.
301In order to prevent this, the existing function can be assigned to an new
302variable and called using this name in the plug-in `OnStateChange` code chunk.
303
304See this example in the plug-in `bash_functions.lua`:
305================================================================================
306
307[source,lua]
308--------------------------------------------------------------------------------
309function syntaxUpdate(desc)
310  if desc=="Bash" then
311
312  table.insert( Keywords,
313                  { Id=5, Regex=[[(\w+)\s*\(]]
314                  } )
315
316    if OnStateChange ~= nil then
317      OrigOnStateChange = OnStateChange;
318    end
319
320    -- add keywords to list 5 if pattern matches
321    function OnStateChange(oldState, newState, token, kwgroup)
322
323      if newState==HL_KEYWORD and kwgroup==5 then
324        AddKeyword(token, 5)
325        return newState
326      end
327      if OrigOnStateChange then
328        return OrigOnStateChange(oldState, newState, token, kwgroup)
329      end
330    end
331
332  end
333end
334--------------------------------------------------------------------------------
335
336
337=== FUNCTION OVERRIDEPARAM
338
339[[OverrideParam]]
340This function enables modification of internal default values concerning the
341parser or output formats. This function is experimental and subject to change.
342Currently it supports these parameters:
343
344[horizontal]
345`state.string.raw`    :: `true` or `false`
346`format.maskws`       :: `true` or `false`
347`format.spacer`       :: whitespace format string
348
349See `langDefs/toml.lang` and `plugins/outhtml_ie7_webctrl.lua` for examples.
350
351................................................................................
352OverrideParam(keyword, kwGroupID)
353
354  Parameters: paramName:   name of configuration item
355              paramVal:    value
356  Returns:    true if successful
357................................................................................
358
359
360=== DECORATE FUNCTIONS
361
362[[Decorate]]
363The `Decorate` function is a hook which is called if a syntax token has been
364identified. It can be used to alter the token or to add additional text in the
365target output format (e.g. hyperlinks).
366
367................................................................................
368Decorate(token, state, kwGroupID, lineHasStmt, lineno, column)
369
370  Hook Event: Token identification
371  Parameters: token:       current token
372              state:       current state
373              kwGroupID:   if state is HL_KEYWORD, the parameter
374                           contains the keyword group ID
375              lineHasStmt: true if current line contains a statement
376              lineno:    line number (since 3.60)
377              column:    line column (since 3.60)
378  Returns:    Altered token string or nothing if original token should be
379              outputted
380................................................................................
381
382Examples:
383
384[source,lua]
385--------------------------------------------------------------------------------
386function Decorate(token, state)
387  if (state == HL_KEYWORD) then
388    return string.upper(token)
389  end
390end
391--------------------------------------------------------------------------------
392
393This function converts all keywords to upper case.
394
395The functions `DecorateLineBegin` and `DecorateLineEnd` are called if a new line
396starts or ends. They can be used to add special formatting to lines of code.
397
398[[DecorateLineBegin]]
399................................................................................
400DecorateLineBegin(lineNumber)
401
402  Hook Event: output of a new line
403  Parameters: lineNumber: the current line number
404  Returns:    A string to be prepended to a new line (or nothing)
405................................................................................
406
407[[DecorateLineEnd]]
408................................................................................
409DecorateLineEnd(lineNumber)
410
411  Hook Event: output of a line ending
412  Parameters: lineNumber: the current line number
413  Returns:    A string to be appended to a line (or nothing)
414................................................................................
415
416
417[IMPORTANT]
418================================================================================
419The return value of `Decorate` functions will be embedded in the formatting tags
420of the output format.
421The return values are not modified or validated by highlight.
422================================================================================
423
424=== FUNCTION STOREVALUE
425
426[[StoreValue]]
427................................................................................
428StoreValue(name, value)
429
430  Set or get a value to exchange information across Lua states
431  Parameters: name: the parameter name
432              value: the parameter value
433  Returns:   if value is not set, the previously assigned value of name
434................................................................................
435
436
437== THEME CHUNK ELEMENTS
438
439The following list includes all those items which you can overwrite or extend to
440adjust the formatting (colour and font attributes) of the output:
441
442Output formatting items:
443
444[horizontal]
445`Default`                 :: table
446`Canvas`                  :: table
447`Number`                  :: table
448`Escape`                  :: table
449`String`                  :: table
450`StringPreProc`           :: table
451`BlockComment`            :: table
452`PreProcessor`            :: table
453`LineNum`                 :: table
454`Operator`                :: table
455`LineComment`             :: table
456`Keywords`                :: table
457
458Read only (output document format):
459
460[horizontal]
461`HL_OUTPUT`               :: number
462`HL_FORMAT_HTML`          :: number
463`HL_FORMAT_XHTML`         :: number
464`HL_FORMAT_TEX`           :: number
465`HL_FORMAT_LATEX`         :: number
466`HL_FORMAT_RTF`           :: number
467`HL_FORMAT_ANSI`          :: number
468`HL_FORMAT_XTERM256`      :: number
469`HL_FORMAT_TRUECOLOR`     :: number
470`HL_FORMAT_SVG`           :: number
471`HL_FORMAT_BBCODE`        :: number
472`HL_FORMAT_PANGO`         :: number
473`HL_FORMAT_ODT`           :: number
474
475Add additional styling information:
476
477[horizontal]
478`Injections`              :: table
479
480[horizontal]
481`StoreValue`              :: function
482
483
484=== FUNCTION STOREVALUE
485
486[[StoreValue]]
487................................................................................
488Like above.
489................................................................................
490
491
492== FORMAT CHUNK ELEMENTS
493
494Read only (output document format):
495
496[horizontal]
497`HL_OUTPUT`               :: number
498`HL_FORMAT_HTML`          :: number
499`HL_FORMAT_XHTML`         :: number
500`HL_FORMAT_TEX`           :: number
501`HL_FORMAT_LATEX`         :: number
502`HL_FORMAT_RTF`           :: number
503`HL_FORMAT_ANSI`          :: number
504`HL_FORMAT_XTERM256`      :: number
505`HL_FORMAT_TRUECOLOR`     :: number
506`HL_FORMAT_SVG`           :: number
507`HL_FORMAT_BBCODE`        :: number
508`HL_FORMAT_PANGO`         :: number
509`HL_FORMAT_ODT`           :: number
510
511Functions:
512
513[horizontal]
514`DocumentHeader`          :: function
515`DocumentFooter`          :: function
516
517
518=== DOCUMENTHEADER FUNCTION
519
520[[DocumentHeader]]
521................................................................................
522DocumentHeader(numFiles, currFile, options)
523
524  Hook Event: output of a new file's header
525  Parameters: numFiles: number of files to be generated
526              currFile: current file counter
527              options: Map of the following options
528              options.title: document title
529              options.encoding: document encoding
530              options.fragment: true if header/footer should not be outputted
531              options.font: font name
532              options.fontsize: font size
533
534  Returns:    [string, boolean?] (or nothing)
535              The string contains the new document header
536              The boolean value indicates if the string should replace the default
537              header (false=default) or if it should be appended to it (true).
538................................................................................
539
540
541=== DOCUMENTFOOTER FUNCTION
542
543[[DocumentFooter]]
544................................................................................
545DocumentFooter(numFiles, currFile, options)
546
547  Hook Event: output of a new file's footer
548  Parameters: see DocumentHeader
549
550  Returns:    [string, boolean?] (or nothing)
551              The string contains the new document footer
552              The boolean value indicates if the string should replace the default
553              footer (false=default) or if it should precede it (true).
554................................................................................
555
556
557== STEP BY STEP
558
559This example will add reference hyperlinks to Qt keywords:
560
561[source,lua]
562--------------------------------------------------------------------------------
563-- first add a description of what the plug-in does
564Description="Add qtproject.org reference links to HTML, LaTeX or RTF output"
565
566-- define the plugin categories (ie. supported output formats; languages)
567Categories = {"c++", "qt" }
568
569-- the syntaxUpdate function contains code related to syntax recognition
570function syntaxUpdate(desc)
571
572  -- if the current file is no C++ file we exit
573  if desc~="C and C++" then
574     return
575  end
576
577  -- this function returns a qt-project reference link of the given token
578  function getURL(token)
579     -- generate the URL
580     url='http://qt-project.org/doc/qt-4.8/'..string.lower(token).. '.html'
581
582     -- embed the URL in a hyperlink according to the output format
583     -- first HTML, then LaTeX and RTF
584     if (HL_OUTPUT== HL_FORMAT_HTML or HL_OUTPUT == HL_FORMAT_XHTML) then
585         return '<a class="hl" target="new" href="'
586                .. url .. '">'.. token .. '</a>'
587     elseif (HL_OUTPUT == HL_FORMAT_LATEX) then
588         return '\\href{'..url..'}{'..token..'}'
589     elseif (HL_OUTPUT == HL_FORMAT_RTF) then
590         return '{{\\field{\\*\\fldinst HYPERLINK "'
591                ..url..'" }{\\fldrslt\\ul\\ulc0 '..token..'}}}'
592     end
593   end
594
595  -- the Decorate function will be invoked for every recognized token
596  function Decorate(token, state)
597
598    -- we are only interested in keywords, preprocessor or default items
599    if (state ~= HL_STANDARD and state ~= HL_KEYWORD and
600        state ~=HL_PREPROC) then
601      return
602    end
603
604    -- Qt keywords start with Q, followed by an upper and a lower case letter
605    -- if this pattern applies to the token, we return the URL
606    -- if we return nothing, the token is outputted as is
607    if string.find(token, "Q%u%l")==1 then
608      return getURL(token)
609    end
610
611  end
612end
613
614-- the themeUpdate function contains code related to the theme
615function themeUpdate(desc)
616  -- the Injections table can be used to add style information to the theme
617
618  -- HTML: we add additional CSS style information to beautify hyperlinks,
619  -- they should have the same color as their surrounding tags
620  if (HL_OUTPUT == HL_FORMAT_HTML or HL_OUTPUT == HL_FORMAT_XHTML) then
621    Injections[#Injections+1]=
622      "a.hl, a.hl:visited {color:inherit;font-weight:inherit;}"
623
624  -- LaTeX: hyperlinks require the hyperref package, so we add this here
625  -- the colorlinks and pdfborderstyle options remove ugly boxes in the output
626  elseif (HL_OUTPUT==HL_FORMAT_LATEX) then
627    Injections[#Injections+1]=
628      "\\usepackage[colorlinks=false, pdfborderstyle={/S/U/W 1}]{hyperref}"
629  end
630end
631
632-- let highlight load the chunks
633Plugins={
634  { Type="lang", Chunk=syntaxUpdate },
635  { Type="theme", Chunk=themeUpdate },
636}
637--------------------------------------------------------------------------------
638
639
640== EXAMPLES
641
642
643The {plugins} directory contains example scripts, including:
644
645{bash_functions_lua}::
646+
647[horizontal]
648Description ::: Add function names to keyword list.
649Features    ::: Adds new keyword group based on a regex, defines `OnStateChange`,
650                uses `AddKeyword`.
651
652{theme_invert_lua}::
653+
654[horizontal]
655Description ::: Invert colours of the original theme.
656Features    ::: Modifies all color attributes of the theme script, uses Lua
657                pattern matching.
658
659{cpp_ref_cplusplus_com_lua}::
660+
661[horizontal]
662Description ::: Add qtproject.org reference links to HTML, LaTeX or RTF output of
663                C++ code.
664Features    ::: Uses `Decorate` to add hyperlinks for a defined set of C++ keywords. +
665                Adds CSS styles with `Injections`.
666
667{ctags_html_tooltips_lua}::
668+
669[horizontal]
670Description ::: Add tooltips based on a ctags file (default input file: tags).
671Features    ::: Uses file input (defined by cli option `--plug-in-param`) and
672                parses tags data before `Decorate` is called.
673
674{outhtml_curly_brackets_matcher_lua}::
675+
676[horizontal]
677Description ::: Shows matching curly brackets in HTML output.
678Features    ::: Uses `Decorate` to add span tags with unique ids to opening and
679                closing brackets. +
680                Adds JavaScript with `HeaderInjection` variable. +
681                Inserts additional CSS styles with `Injections` variable.
682
683{outhtml_keyword_matcher_lua}::
684+
685[horizontal]
686Description ::: Shows matching keywords in HTML output.
687Features    ::: Uses `Decorate` to add span tags with unique ids to keywords. +
688                Uses `OnStateChange` to assign an internal ID to each keyword. +
689                Adds JavaScript with `HeaderInjection` variable. +
690                Inserts additional CSS styles with `Injections` variable. +
691
692{outhtml_codefold_lua}::
693+
694[horizontal]
695Description ::: Adds code folding for C style languages, Pascal, Lua and Ruby to
696                HTML output.
697Features    ::: Uses `DecorateLineBegin` and `DecorateLineEnd` to add ID-spans to each
698                line. +
699                Applies `Decorate` to each code block delimiter to add `onClick` event
700                handlers. +
701                Adds JavaScript with `HeaderInjection` and `FooterInjection` variables. +
702                Inserts additional CSS styles with `Injections` variable.
703
704
705== PLUG-IN USAGE
706
707[discrete]
708=== Command line interface
709
710Run highlight `--list-scripts=plugins` to show all installed plug-ins.
711
712Use `--plug-in` to load a plug-in script file.
713This option can be applied more than once to apply several plug-ins.
714Omit the `.lua` suffix.
715You can store your plug-in scripts for testing in `~/.highlight/plugins`.
716
717.Example
718
719................................................................................
720highlight my.cpp -Ilz --plug-in=html_curly_brackets_matcher > ~/test_out/my.html
721................................................................................
722
723
724[discrete]
725=== GUI
726
727Add the plug-in scripts in the plug-in selection tab and enable them using the
728checkboxes.
729
730
731// EOF //
732

README_REGEX.adoc

1= HIGHLIGHT REGULAR EXPRESSIONS MANUAL
2André Simon
3:lang: en
4:toc: left
5:toc-title: Contents
6:toclevels: 4
7:sectnums!:
8:sectanchors:
9// Misc Settings:
10:experimental: true
11:icons: font
12:linkattrs: true
13
14// =====================================
15// Custom Attributes for Reference Links
16// =====================================
17// External Links:
18:GNU-regex-library: pass:[https://www.gnu.org/software/regex/[GNU regular expression library^]]
19
20
21This file is based on the original Boost API documentation:
22
23* http://www.boost.org/doc/libs/1_32_0/libs/regex/doc/syntax.html
24
25Regular expressions can be applied in highlight's syntax definitions.
26
27== Literals
28
29All characters are literals except: `.`, `|`, `*`, `?`, `+`, `(`, `)`, `{`, `}`,
30`[`, `]`, `^`, `$` and `\`.
31These characters are literals when preceded by a `\`.
32A literal is a character that matches itself, or matches the result of
33`traits_type::translate()`, where `traits_type` is the traits template parameter to
34class `basic_regex`.
35
36== Wildcard
37
38The dot character `.` matches any single character except: when
39`match_not_dot_null` is passed to the matching algorithms, the dot does not
40match a null character; when `match_not_dot_newline` is passed to the matching
41algorithms, then the dot does not match a newline character.
42
43
44== Repeats
45
46A repeat is an expression that is repeated an arbitrary number of times.
47
48An expression followed by `*` can be repeated any number of times including zero.
49
50An expression followed by `+` can be repeated any number of times, but at least
51once, if the expression is compiled with the flag `regex_constants::bk_plus_qm`
52then `+` is an ordinary character and `\+` represents a repeat of once or more.
53
54An expression followed by `?` may be repeated zero or one times only, if the
55expression is compiled with the flag `regex_constants::bk_plus_qm` then `?` is an
56ordinary character and `\?` represents the repeat zero or once operator.
57
58When it is necessary to specify the minimum and maximum number of repeats explicitly,
59the bounds operator `{}` may be used, thus `a{2}` is the letter `a` repeated
60exactly twice, `a{2,4}` represents the letter `a` repeated between 2 and 4
61times, and `a{2,}` represents the letter `a` repeated at least twice with no
62upper limit.
63
64Note that there must be no white-space inside the `{}`, and there is
65no upper limit on the values of the lower and upper bounds.
66
67When the expression is compiled with the flag `regex_constants::bk_braces` then
68`{` and `}` are ordinary characters and `\{` and `\}` are used to delimit bounds
69instead.
70
71All repeat expressions refer to the shortest possible previous sub-expression: a
72single character; a character set, or a sub-expression grouped with `()` for
73example.
74
75[discrete]
76=== Examples
77
78[horizontal]
79`ba*`       ::  will match all of "`b`", "`ba`", "`baaa`" etc.
80`ba+`       ::  will match "`ba`" or "`baaaa`" for example but not "`b`".
81`ba?`       ::  will match "`b`" or "`ba`".
82`ba{2,4}`   ::  will match "`baa`", "`baaa`" and "`baaaa`".
83
84
85== Non-greedy repeats
86
87Whenever the `extended` regular expression syntax is in use (the default) then
88non-greedy repeats are possible by appending a `?` after the repeat; a
89non-greedy repeat is one which will match the shortest possible string.
90
91For example to match html tag pairs one could use something like:
92
93......................................
94<\s*tagname[^>]*>(.*?)<\s*/tagname\s*>
95......................................
96
97In this case `$1` will contain the text between the tag pairs, and will be the
98shortest possible matching string.
99
100
101== Parenthesis
102
103Parentheses serve two purposes, to group items together into a sub-expression,
104and to mark what generated the match.
105For example the expression `(ab)*` would match all of the string "`ababab`".
106
107The matching algorithms `regex_match` and `regex_search` each take an instance
108of `match_results` that reports what caused the match, on exit from these
109functions the `match_results` contains information both on what the whole
110expression matched and on what each sub-expression matched.
111
112In the example above `match_results[1]` would contain a pair of iterators
113denoting the final "`ab`" of the matching string.
114
115It is permissible for sub-expressions to match null strings.
116
117If a sub-expression takes no part in a match -- for example if it is part of an
118alternative that is not taken -- then both of the iterators that are returned for
119that sub-expression point to the end of the input string, and the matched
120parameter for that sub-expression is false.
121
122Sub-expressions are indexed from left to right starting from 1, sub-expression 0
123is the whole expression.
124
125
126== Non-Marking Parenthesis
127
128Sometimes you need to group sub-expressions with parenthesis, but don't want the
129parenthesis to spit out another marked sub-expression, in this case a
130non-marking parenthesis `(?:expression)` can be used.
131
132For example the following expression creates no sub-expressions:
133
134................................................................................
135(?:abc)*
136................................................................................
137
138
139== Forward Lookahead Asserts
140
141There are two forms of these; one for positive forward lookahead asserts, and
142one for negative lookahead asserts:
143
144[horizontal]
145`(?=abc)` :: matches zero characters only if they are followed by the expression "`abc`".
146`(?!abc)` :: matches zero characters only if they are not followed by the expression "`abc`".
147
148
149== Independent sub-expressions
150
151`(?>expression)` matches `expression` as an independent atom (the algorithm will
152not backtrack into it if a failure occurs later in the expression).
153
154
155== Alternatives
156
157Alternatives occur when the expression can match either one sub-expression or
158another, each alternative is separated by a `|`, or a `\|` if the flag
159`regex_constants::bk_vbar` is set, or by a newline character if the flag
160`regex_constants::newline_alt` is set.
161
162Each alternative is the largest possible previous sub-expression; this is the
163opposite behavior from repetition operators.
164
165[discrete]
166=== Examples:
167
168[horizontal]
169`a(b|c)`  :: could match "`ab`" or "`ac`".
170`abc|def` :: could match "`abc`" or "`def`".
171
172
173== Sets
174
175A set is a set of characters that can match any single character that is a
176member of the set.
177Sets are delimited by `[` and `]` and can contain literals,
178character ranges, character classes, collating elements and equivalence classes.
179Set declarations that start with `^` contain the complement of the elements that
180follow.
181
182[discrete]
183=== Examples:
184
185
186Character literals:
187
188[horizontal]
189`[abc]`    :: will match either of "`a`", "`b`", or "`c`".
190`[^abc]`   :: will match any character other than "`a`", "`b`", or "`c`".
191
192Character ranges:
193
194[horizontal]
195`[a-z]`    :: will match any character in the range "`a`" to "`z`".
196`[^A-Z]`   :: will match any character other than those in the range "`A`" to "`Z`".
197
198Note that character ranges are highly locale dependent if the flag
199`regex_constants::collate` is set: they match any character that collates between
200the endpoints of the range, ranges will only behave according to ASCII rules
201when the default "`C`" locale is in effect.
202
203For example if the library is compiled with the Win32 localization model, then
204`[a-z]` will match the ASCII characters a-z, and also '`A`', '`B`' etc, but not
205'`Z`' which collates just after '`z`'.
206
207This locale specific behavior is disabled by default (in perl mode), and forces ranges to collate according to ASCII character code.
208
209Character classes are denoted using the syntax `[:classname:]` within a set
210declaration, for example `[[:space:]]` is the set of all whitespace characters.
211Character classes are only available if the flag `regex_constants::char_classes`
212is set.
213
214The available character classes are:
215
216[cols="10m,90d",options="header"]
217|===============================================================================
218| class  | description
219
220| alnum   | Any alpha numeric character.
221| alpha   | Any alphabetical character a-z and A-Z. Other characters may also be
222            included depending upon the locale.
223| blank   | Any blank character, either a space or a tab.
224| cntrl   | Any control character.
225| digit   | Any digit 0-9.
226| graph   | Any graphical character.
227| lower   | Any lower case character a-z. Other characters may also be included
228            depending upon the locale.
229| print   | Any printable character.
230| punct   | Any punctuation character.
231| space   | Any whitespace character.
232| upper   | Any upper case character A-Z. Other characters may also be included
233            depending upon the locale.
234| xdigit  | Any hexadecimal digit character, 0-9, a-f and A-F.
235| word    | Any word character - all alphanumeric characters plus the underscore.
236| Unicode | Any character whose code is greater than 255, this applies to the
237            wide character traits classes only. (not applicable in highlight)
238|===============================================================================
239
240There are some shortcuts that can be used in place of the character classes,
241provided the flag `regex_constants::escape_in_lists` is set then you can use:
242
243[horizontal]
244`\w`  :: in place of `[:word:]`
245`\s`  :: in place of `[:space:]`
246`\d`  :: in place of `[:digit:]`
247`\l`  :: in place of `[:lower:]`
248`\u`  :: in place of `[:upper:]`
249
250Collating elements take the general form `[.tagname.]` inside a set declaration,
251where _tagname_ is either a single character, or a name of a collating element,
252for example `[[.a.]]` is equivalent to `[a]`, and `[[.comma.]]` is equivalent to `[,]`.
253
254The library supports all the standard POSIX collating element names, and in
255addition the following digraphs: `ae`, `ch`, `ll`, `ss`, `nj`, `dz`, `lj`, each
256in lower, upper and title case variations.
257
258Multi-character collating elements can result in the set matching more than one
259character, for example `[[.ae.]]` would match two characters, but note that
260`[^[.ae.]]` would only match one character.
261
262Equivalence classes take the general form `[=tagname=]` inside a set declaration,
263where _tagname_ is either a single character, or a name of a collating element,
264and matches any character that is a member of the same primary equivalence class
265as the collating element `[.tagname.]`.
266
267An equivalence class is a set of characters that collate the same, a primary
268equivalence class is a set of characters whose primary sort key are all the same
269(for example strings are typically collated by character, then by accent, and
270then by case; the primary sort key then relates to the character, the secondary
271to the accentation, and the tertiary to the case).
272
273If there is no equivalence class corresponding to _tagname_, then `[=tagname=]` is
274exactly the same as `[.tagname.]`.
275
276Unfortunately there is no locale independent method of obtaining the primary
277sort key for a character, except under Win32.
278
279For other operating systems the library will "`guess`" the primary sort key from
280the full sort key (obtained from `strxfrm`), so equivalence classes are probably
281best considered broken under any operating system other than Win32.
282
283To include a literal `-` in a set declaration then: make it the first character
284after the opening `[` or `[^`, the endpoint of a range, a collating element, or
285if the flag `regex_constants::escape_in_lists` is set then precede with an escape
286character as in `[\-]`.
287
288To include a literal `[` or `]` or `^` in a set then make them the endpoint of a
289range, a collating element, or precede with an escape character if the flag
290`regex_constants::escape_in_lists` is set.
291
292
293== Line anchors
294
295An anchor is something that matches the null string at the start or end of a
296line: `^` matches the null string at the start of a line, `$` matches the null
297string at the end of a line.
298
299
300== Back references
301
302A back reference is a reference to a previous sub-expression that has already
303been matched, the reference is to what the sub-expression matched, not to the
304expression itself.
305
306A back reference consists of the escape character `\` followed by a digit `1` to
307`9`, `\1` refers to the first sub-expression, `\2` to the second etc.
308
309For example the expression `(.*)\1` matches any string that is repeated about
310its mid-point for example "`abcabc`" or "`xyzxyz`".
311
312A back reference to a sub-expression that did not participate in any match,
313matches the null string: NB this is different to some other regular expression
314matchers.
315
316Back references are only available if the expression is compiled with the flag
317`regex_constants::bk_refs` set.
318
319
320
321== Word operators
322
323The following operators are provided for compatibility with the {GNU-regex-library}.
324
325[horizontal]
326`\w` :: matches any single character that is a member of the `word` character
327        class, this is identical to the expression `[[:word:]]`.
328`\W` :: matches any single character that is not a member of the `word` character
329        class, this is identical to the expression `[^[:word:]]`.
330`\<` :: matches the null string at the start of a word.
331`\>` :: matches the null string at the end of the word.
332`\b` :: matches the null string at either the start or the end of a word.
333`\B` :: matches a null string within a word.
334
335The start of the sequence passed to the matching algorithms is considered to be
336a potential start of a word unless the flag `match_not_bow` is set.
337
338The end of the sequence passed to the matching algorithms is considered to be a
339potential end of a word unless the flag `match_not_eow` is set.
340
341
342== Buffer operators
343
344The following operators are provided for compatibility with the {GNU-regex-library},
345and Perl regular expressions:
346
347[horizontal]
348`\`` :: matches the start of a buffer.
349`\A` :: matches the start of the buffer.
350`\'` :: matches the end of a buffer.
351`\z` :: matches the end of a buffer.
352`\Z` :: matches the end of a buffer, or possibly one or more new line characters
353        followed by the end of the buffer.
354
355A buffer is considered to consist of the whole sequence passed to the matching
356algorithms, unless the flags `match_not_bob` or `match_not_eob` are set.
357
358
359== Escape operator
360
361The escape character `\` has several meanings.
362
363Inside a set declaration the escape character is a normal character unless the
364flag `regex_constants::escape_in_lists` is set in which case whatever follows the
365escape is a literal character regardless of its normal meaning.
366
367The escape operator may introduce an operator for example: back references, or a
368word operator.
369
370The escape operator may make the following character normal, for example `\*`
371represents a literal `*` rather than the repeat operator.
372
373// @ARRIVED HERE
374
375
376== Single character escape sequences
377
378The following escape sequences are aliases for single characters:
379
380
381[cols="2*10m,80d",options="header"]
382|===============================================================================
383| Escape | Char  | Meaning
384| \a     | 0x07  | Bell character.
385| \f     | 0x0C  | Form feed.
386| \n     | 0x0A  | Newline character.
387| \r     | 0x0D  | Carriage return.
388| \t     | 0x09  | Tab character.
389| \v     | 0x0B  | Vertical tab.
390| \e     | 0x1B  | ASCII Escape character.
391| \0dd   | 0dd   | Bell character.
392| \xXX   | 0xXX  | A hexadecimal character code, where _XX_ is one or more
393                   hexadecimal digits
394| \x{XX} | 0xXX  | A hexadecimal character code, where _XX_ is one or more
395                   hexadecimal digits, optionally a Unicode character.
396| \cZ    | z-@   | An ASCII escape sequence control-Z, where _Z_ is any ASCII
397                   character greater than or equal to the code for `@`.
398|===============================================================================
399
400
401== Miscellaneous escape sequences:
402
403The following are provided mostly for perl compatibility, but note that there
404are some differences in the meanings of `\l`, `\L`, `\u` and `\U`:
405
406[horizontal]
407`\w` :: Equivalent to `[[:word:]]`.
408`\W` :: Equivalent to `[^[:word:]]`.
409`\s` :: Equivalent to `[[:space:]]`.
410`\S` :: Equivalent to `[^[:space:]]`.
411`\d` :: Equivalent to `[[:digit:]]`.
412`\D` :: Equivalent to `[^[:digit:]]`.
413`\l` :: Equivalent to `[[:lower:]]`.
414`\L` :: Equivalent to `[^[:lower:]]`.
415`\u` :: Equivalent to `[[:upper:]]`.
416`\U` :: Equivalent to `[^[:upper:]]`.
417`\C` :: Any single character, equivalent to `.`.
418`\X` :: Match any Unicode combining character sequence, for example `a\x0301`
419        (a letter a with an acute).
420`\Q` :: The begin quote operator, everything that follows is treated as
421        a literal character until a `\E` end quote operator is found.
422`\E` :: The end quote operator, terminates a sequence begun with `\Q`.
423
424[discrete]
425=== Examples:
426
427`Regex=[[ [A-Z]\w+ ]]` +
428Highlight identifiers beginning with a capital letter.
429
430`Regex=[[ [$@%]\w+ ]]` +
431Highlight variables beginning with $, @ or %.
432
433`Regex=[[ \$\{(\w+)\}) ]]` or `Regex=[[ \$\{(\w+)\} ]], Group=1` +
434Highlight variable names like "`${name}`".
435Only the name is highlighted as keyword.
436A sub-expression is used to achieve this effect.
437If no sub-expression number
438is defined (like in the first example above), the right-most sub match
439(highest sub id) is returned.
440
441`Regex=[[ (\w+)\s*\( ]]` +
442Highlight method names.
443Note that a sub expression is used again.
444
445`Regex=[[STO\xe2\x88\x91]]` +
446Unicode characters in a keyword.
447
448`[[\A(?!x)x]]` +
449A never matching expression.
450Can be used to disable a default syntax element.
451
452'''
453
454Andre Simon
455
456a.simon@mailbox.org
457
458http://www.andre-simon.de/
459
460Git project with Git repository, bug tracker:
461
462* https://gitlab.com/saalen/highlight/
463
464
465// EOF //
466

README_RELEASE.adoc

1= HIGHLIGHT IMPORTANT RELEASE AND PACKAGING INFORMATION
2André Simon
3:revdate: February 2021
4:lang: en
5:toc: left
6:toc-title: Contents
7:toclevels: 4
8:sectnums:
9:sectnumlevels: 2
10:sectanchors:
11// Misc Settings:
12:experimental: true
13:icons: font
14:linkattrs: true
15
16// =====================================
17// Custom Attributes for Reference Links
18// =====================================
19// Highlight Docs (uncovenrted):
20:INSTALL: pass:q[link:INSTALL[`INSTALL`]]
21// Source files:
22:bclear: pass:q[link:themes/bclear.theme[bclear^]]
23:src_makefile: pass:q[link:src/makefile[`src/makefile`^]]
24
25== GIT: FIRST COMMIT -- THEN EXPORT
26
27Triple check.
28
29== TESTS
30
31........................
32highlight --print-config
33........................
34
35This will print the config file search paths and compilation options.
36
37
38To test syntax definitions, run
39
40..............................
41highlight --list-scripts=langs
42..............................
43
44This command compiles all syntax scripts.
45
46................................
47highlight --list-scripts=themes
48highlight --list-scripts=plugins
49................................
50
51These commands show installed files.
52
53
54To quickly test highlighting on the command line, type:
55
56................................
57highlight -ISc
58................................
59
60Now type some C code and hit kbd:[CTRL+D] to quit.
61
62Add `--verbose` to print additional syntax parsing information.
63
64
65Test filetype recognition:
66
67* file suffix (default)
68* no suffix (i.e. makefile)
69* shebang (i.e. Bash script)
70* force syntax using `-S` and `--syntax-by-name`
71
72
73== UNNEEDED FILES
74
75Remove `src/gui-qt/.qmake.stash`
76
77
78== THIRD PARTY COMPATIBILITY
79
80The following options are used in third party applications:
81
82* `--input, -i`
83* `--output, -o`
84* `--encoding, -u`
85* `--font`
86* `--font-size`
87* `--force`
88* `--line-numbers, -l`
89* `--replace-tabs, -t`
90* `--syntax`
91* `--syntax-by-name`
92* `--out-format`
93* `--include-style`
94* `--inline-css`
95* `--style`
96* `--failsafe`
97* `--validate-input`
98
99The following themes are used in third party applications:
100
101* {bclear} (Evolution)
102
103The following platform dependent classes are used in SWIG scripts (ikiwiki):
104
105* `DataDir`
106
107
108== SO-LIB VERSION
109
110Increase `SO_VERSION` in {src_makefile}.
111
112
113See the makefiles and {INSTALL} for more packaging information.
114
115
116// EOF //
117

README_TESTCASES.adoc

1= HIGHLIGHT TESTCASES MANUAL
2André Simon
3v4.0, March 2021
4:lang: en
5:icons: font
6:toc: left
7:toc-title: Contents
8:toclevels: 4
9:sectnums:
10:sectnumlevels: 1
11:sectanchors:
12// GitHub Settings to enable Admonitions Icons in preview:
13ifdef::env-github[]
14:caution-caption: :fire:
15:important-caption: :heavy_exclamation_mark:
16:note-caption: :information_source:
17:tip-caption: :bulb:
18:warning-caption: :warning:
19endif::[]
20
21== ABOUT
22
23Input files whose filenames start with `syntax_test_` can contain column and state
24indicators in comment sections to test the highlight syntax recognition of the
25previous line. If such a test fails, highlight will print an error message and
26exit with FAILURE return value.
27
28See the feature discussion here: https://gitlab.com/saalen/highlight/issues/80
29
30
31[NOTE]
32================================================================================
33For UTF-8 encoded input, you need to set `--encoding=utf-8`. Otherwise the
34state indicator positions will not be calculated correctly.
35================================================================================
36
37
38[NOTE]
39================================================================================
40Only the last 100 states of each input line are being tracked.
41================================================================================
42
43
44== TEST CASE NOTATION
45
46A test case is defined by two entities: column and expected state.
47
48The column is defined by ``^`` ("here") or ``<`` ("comment start / first column").
49
50The state is defined by one of the following identifiers:
51
52[horizontal]
53`def` :: standard / no recognition // SEE V4 migration note below
54`sng` :: string                    // SEE V4 migration note below
55`num` :: number
56`slc` :: single line comment
57`com` :: multiline comment
58`esc` :: escape character
59`ppc` :: preprocessor
60`pps` :: preprocessor string
61`opt` :: operator
62`ipl` :: interpolation
63`ws`  :: whitespace
64`kwX`  :: keyword group X (X: a..z)
65`stX`  :: semantic token X (X: a..z)
66
67The state identifiers match the corresponding HTML output CSS class names.
68
69Since release 3.47, the whitespace indicator `ws` is no longer exclusive.
70A test will succeed at a position with whitespace if the enclosing state is matched
71or if `ws` is tested specifically.
72
73V4 migration: For a smooth transition after the V4 release, `std` will be recognized
74as `def`, and `str` is equivalent to `sng`.
75
76Add a leading `~` to an indicator to match any other state as success.
77
78
79=== Example
80
81The following C file `syntax_test_1.c` contains various state indicators:
82
83[source,C]
84--------------------------------------------------------------------------------
85#include <iostream>
86#include "myheader"
87// ^ ppc ^^^^^^^^^^ pps       1)
88
89int main() {
90//  ^^^^ kwd                  2)
91/* comment comment comment
92 * <  com ^ ws     ^ com      3)
93 */
94
95    int var =   0x1234;
96/*      ^^^ def ^    ^ num */
97//          ^ opt             4)
98    std::cout << "whatever: " << var <<   "\n";
99//               ^^^^^^^^^^^^ str    ^^opt ^^ esc
100    return 0;
101    //  <   kwa               5)
102}
103--------------------------------------------------------------------------------
104
1051) This line contains a test for preprocessor and a preprocessor string.
106   The `^` indicators point at the tested string sections of the previous line.
107
1082) The keyword group `kwd` is checked (functions are highlighted as `kwd` in C syntax)
109
1103) The `<` points to column 0 as the comment starts there.
111   `ws` tests for whitespace.
112
1134) A source code line can be tested with various test comments.
114   Here the `opt` test looks for the operator two lines before.
115
1165) `<` points at column 4, the beginning of the comment.
117
118
119Running highlight with this file will not produce any additional output, as all
120tests pass. The exit status will be 0.
121
122If you change the `kwa` in 5 to `kwb` (or any other state), highlight will print
123an error like this, and exit with status 1:
124
125.........................................................
126highlight: Could not validate file:
127syntax_test_1.c line 17, column 4: got kwa instead of kwb
128.........................................................
129
130
131The highlight GUI will show error messages in an error summary prompt.
132
133

README_V4_MIGRATION.adoc

1= HIGHLIGHT VERSION 4.0 MIGRATION
2André Simon
3:revdate: March 2021
4:lang: en
5:toc: left
6:toc-title: Contents
7:toclevels: 4
8:sectnums:
9:sectnumlevels: 2
10:sectanchors:
11// Misc Settings:
12:experimental: true
13:icons: font
14:linkattrs: true
15
16
17The major version bump will be used to enforce the following interface
18and file changes:
19
20
21== REMOVED CLI OPTIONS
22
23The following options will be removed:
24+
25..........................................................................
26    --start-nested=<lang>      define nested language which starts input
27                                  without opening delimiter
28
29    --reformat=user
30    --reformat-option=<opt>    apply an astyle cmd line option (assumes -F)
31
32    --base16[=theme]           use a theme of the Base16 collection
33
34    --delim-cr                 set CR as end-of-line delimiter (MacOS 9)
35    --plug-in-read             see --plug-in-param
36..........................................................................
37
38
39These options will no longer be documented but continue to work:
40
41
42=== GNU SOURCE-HIGHLIGHT COMPATIBILITY OPTIONS
43+
44..........................................................................
45    --doc                      create stand alone document
46    --no-doc                   cancel the --doc option
47    --css=filename             the external style sheet filename
48    --src-lang=STRING          source language
49 -t, --tab=INT                  specify tab length
50 -n, --line-number[=0]          number all output lines, optional padding
51    --line-number-ref[=p]      number all output lines and generate an anchor,
52                                made of the specified prefix p + the line
53                                number  (default='line')
54    --output-dir=path          output directory
55    --failsafe                 if no language definition is found for the
56                                  input, it is simply copied to the output
57..........................................................................
58
59A deprecation notice is shown during the beta release cycle.
60
61
62== REMOVED LIBRARY FUNCTIONS
63+
64..........................................................................
65DataDir::searchDataDir -> DataDir::initSearchDirectories
66CodeGenerator::setIndentationOptions
67CodeGenerator::setStartingNestedLang
68..........................................................................
69
70
71=== REMOVED FILES
72+
73..........................................................................
74    extras/web_plugins/*
75..........................................................................
76
77
78=== RENAMED FILES
79+
80..........................................................................
81    langDefs/abap4.lang -> langDefs/abap.lang
82    langDefs/coffee.lang -> langDefs/coffeescript.lang
83    langDefs/docker.lang -> langDefs/dockerfile.lang
84    langDefs/js.lang -> langDefs/javascript.lang
85    langDefs/make.lang -> langDefs/makefile.lang
86    langDefs/ps1.lang -> langDefs/powershell.lang
87    langDefs/rs.lang -> langDefs/rust.lang
88    langDefs/sh.lang -> langDefs/shellscript.lang
89    langDefs/ts.lang -> langDefs/typescript.lang
90
91    themes/fine_blue.theme -> themes/fineblue.theme
92..........................................................................
93
94
95== NEW CONFIG FILES
96+
97
98lsp.conf
99
100
101== STYLE NAMES
102+
103
104To avoid conflicts with new `st*` names, these classes were renamed:
105
106..........................................................................
107    str -> sng
108    std -> def
109..........................................................................
110
111// EOF //
112