{
    "mode": "man",
    "parameter": "highlight",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/highlight/1/json",
    "generated": "2026-10-04T19:14:23Z",
    "synopsis": "highlight [OPTIONS]... [FILES]...",
    "sections": {
        "NAME": {
            "content": "Highlight - a universal sourcecode to formatted text converter\n\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "highlight [OPTIONS]... [FILES]...\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Highlight  converts  sourcecode  to  HTML, XHTML, RTF, ODT, LaTeX, TeX, BBCode, Pango markup,\nSVG, XTERM or ANSI escape sequences.  There are several colour themes  available.   Highlight\nrecognizes  keywords,  numbers,  strings,  comments, symbols and preprocessor directives.  It\nsupports about 180 programming languages, which are defined in Lua scripts.\n\n\nIt's easily possible to enhance highlight's database  of  programming  languages  and  colour\nthemes.  See the README file for details.\n",
            "subsections": []
        },
        "GENERAL OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-B --batch-recursive",
                    "content": "convert all files matching the wildcard (uses recursive search)\n",
                    "flag": "-B",
                    "long": "--batch-recursive"
                },
                {
                    "name": "-D --data-dir",
                    "content": "set path to highlight data directory\n\n--config-file=<file>\nset path to a lang or theme file\n",
                    "flag": "-D",
                    "long": "--data-dir"
                },
                {
                    "name": "-h --help",
                    "content": "print this help or a topic description <topic> = [syntax, theme, plugin, config]\n",
                    "flag": "-h",
                    "long": "--help"
                },
                {
                    "name": "-i --input",
                    "content": "name of input file\n",
                    "flag": "-i",
                    "long": "--input"
                },
                {
                    "name": "-o --output",
                    "content": "name of output file\n",
                    "flag": "-o",
                    "long": "--output"
                },
                {
                    "name": "-d --outdir",
                    "content": "name of output directory\n",
                    "flag": "-d",
                    "long": "--outdir"
                },
                {
                    "name": "-P --progress",
                    "content": "print progress bar in batch mode\n",
                    "flag": "-P",
                    "long": "--progress"
                },
                {
                    "name": "-S --syntax",
                    "content": "set  type  of  source  code, necessary if input file suffix is missing. The syntax may\nalso be defined as path of the language file.\n\n--syntax-by-name=<name>\nspecify type of source code by given name.  Will not read a file of this name,  useful\nfor  stdin  and to determine the syntax of the file before piping its content to high‐\nlight. This option overrides --syntax.\n",
                    "flag": "-S",
                    "long": "--syntax"
                },
                {
                    "name": "--syntax-supported",
                    "content": "test if the given syntax can be loaded and print the result  (assumes -S or  --syntax-\nby-name)\n",
                    "long": "--syntax-supported"
                },
                {
                    "name": "-v --verbose",
                    "content": "print debug info to stderr; repeat to show more information\n",
                    "flag": "-v",
                    "long": "--verbose"
                },
                {
                    "name": "-q --quiet",
                    "content": "suppress progress info in batch mode\n\n--force[=syntax]\ngenerate output if input syntax is unknown. The fallback syntax may be set here, Plain\nText is default.\n\n--list-scripts=<type>\nlist installed scripts <type> = [langs, themes, plugins]\n\n--list-cat=<categories>\nfilter the scripts by the given categories (example: --list-cat='source;script')\n\n--max-size=<size>\nset maximum input file size (examples: 512M, 1G; default: 256M)\n\n--plug-in=<script>\nexecute Lua plug-in script; repeat option to apply multiple plug-ins\n",
                    "flag": "-q",
                    "long": "--quiet"
                },
                {
                    "name": "--plug-in-param",
                    "content": "set plug-in input parameter. This might be an input file name (ie. 'tags').\n",
                    "long": "--plug-in-param"
                },
                {
                    "name": "--print-config",
                    "content": "print path configuration\n",
                    "long": "--print-config"
                },
                {
                    "name": "--print-style",
                    "content": "print stylesheet only (see --style-outfile)\n\n--skip=<list>\nignore listed unknown file types (example: --skip='bak;c~;h~')\n",
                    "long": "--print-style"
                },
                {
                    "name": "--stdout",
                    "content": "output to stdout (batch mode, --print-style)\n",
                    "long": "--stdout"
                },
                {
                    "name": "--validate-input",
                    "content": "test if input is a valid text file\n",
                    "long": "--validate-input"
                },
                {
                    "name": "--service-mode",
                    "content": "run in service mode, not stopping until signaled\n",
                    "long": "--service-mode"
                },
                {
                    "name": "--version",
                    "content": "print version and copyright info\n\n",
                    "long": "--version"
                }
            ]
        },
        "OUTPUT FORMATTING OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-O --out-format",
                    "content": "output  file  in  given  format  <format>=[html,  xhtml,  latex,  tex, rtf, odt, ansi,\nxterm256, truecolor, bbcode, pango, svg]\n",
                    "flag": "-O",
                    "long": "--out-format"
                },
                {
                    "name": "-c --style-outfile",
                    "content": "name of style definition file\n",
                    "flag": "-c",
                    "long": "--style-outfile"
                },
                {
                    "name": "-T --doc-title",
                    "content": "document title\n",
                    "flag": "-T",
                    "long": "--doc-title"
                },
                {
                    "name": "-e --style-infile",
                    "content": "name of file to be included in style-outfile\n",
                    "flag": "-e",
                    "long": "--style-infile"
                },
                {
                    "name": "-f --fragment",
                    "content": "omit header and footer of the output document (see --keep-injections)\n",
                    "flag": "-f",
                    "long": "--fragment"
                },
                {
                    "name": "-F --reformat",
                    "content": "reformat output in given style.  <style>=[allman, gnu, google,  horstmann,  java,  kr,\nlinux, lisp, mozilla, otbs, pico, vtk, ratliff, stroustrup, webkit, whitesmith]\n",
                    "flag": "-F",
                    "long": "--reformat"
                },
                {
                    "name": "-I --include-style",
                    "content": "include style definition in output\n",
                    "flag": "-I",
                    "long": "--include-style"
                },
                {
                    "name": "-J --line-length",
                    "content": "line length before wrapping (see -V, -W)\n",
                    "flag": "-J",
                    "long": "--line-length"
                },
                {
                    "name": "-j --line-number-length",
                    "content": "line number length incl. left padding. Default length: 5\n",
                    "flag": "-j",
                    "long": "--line-number-length"
                },
                {
                    "name": "-k --font",
                    "content": "set font (specific to output format)\n",
                    "flag": "-k",
                    "long": "--font"
                },
                {
                    "name": "-K --font-size",
                    "content": "set font size (specific to output format)\n",
                    "flag": "-K",
                    "long": "--font-size"
                },
                {
                    "name": "-l --line-numbers",
                    "content": "print line numbers in output file\n",
                    "flag": "-l",
                    "long": "--line-numbers"
                },
                {
                    "name": "-m --line-number-start",
                    "content": "start line numbering with cnt (assumes -l)\n\n--line-range=<start-end>\noutput only lines from number <start> to <end>\n",
                    "flag": "-m",
                    "long": "--line-number-start"
                },
                {
                    "name": "-s --style",
                    "content": "set  highlighting style (theme). Add 'base16/' prefix to use a Base16 theme. The theme\nmay also be defined as path of the theme file.\n",
                    "flag": "-s",
                    "long": "--style"
                },
                {
                    "name": "-t  --replace-tabs",
                    "content": "replace tabs by num spaces\n",
                    "flag": "-t",
                    "long": "--replace-tabs"
                },
                {
                    "name": "-u --encoding",
                    "content": "set output encoding which matches input file encoding; omit  encoding  information  if\nset to \"NONE\"\n",
                    "flag": "-u",
                    "long": "--encoding"
                },
                {
                    "name": "-V --wrap-simple",
                    "content": "wrap  lines  after  80  (default) characters without indenting function parameters and\nstatements.\n",
                    "flag": "-V",
                    "long": "--wrap-simple"
                },
                {
                    "name": "-W --wrap",
                    "content": "wrap lines after 80 (default) characters (use with caution).\n",
                    "flag": "-W",
                    "long": "--wrap"
                },
                {
                    "name": "-z --zeroes",
                    "content": "fill leading space of line numbers with zeroes\n",
                    "flag": "-z",
                    "long": "--zeroes"
                },
                {
                    "name": "--isolate",
                    "content": "output each syntax token in separate tags (verbose output)\n",
                    "long": "--isolate"
                },
                {
                    "name": "--keep-injections",
                    "content": "output plug-in header and footer injections in spite of -f\n\n--kw-case=<upper|lower|capitalize>\noutput all keywords in given case if language is not case sensitive\n\n--no-trailing-nl[=mode]\nomit trailing newline. If mode is \"empty-file\", omit only for empty input\n",
                    "long": "--keep-injections"
                },
                {
                    "name": "--no-version-info",
                    "content": "omit version info comment\n",
                    "long": "--no-version-info"
                },
                {
                    "name": "--wrap-no-numbers",
                    "content": "omit line numbers of wrapped lines (assumes -l)\n\n\n(X)HTML OPTIONS",
                    "long": "--wrap-no-numbers"
                },
                {
                    "name": "-a --anchors",
                    "content": "attach anchors to line numbers (HTML only)\n",
                    "flag": "-a",
                    "long": "--anchors"
                },
                {
                    "name": "-y --anchor-prefix",
                    "content": "set anchor name prefix\n",
                    "flag": "-y",
                    "long": "--anchor-prefix"
                },
                {
                    "name": "-N --anchor-filename",
                    "content": "use input file name as anchor name\n",
                    "flag": "-N",
                    "long": "--anchor-filename"
                },
                {
                    "name": "-C --print-index",
                    "content": "print index file with links to all output files\n",
                    "flag": "-C",
                    "long": "--print-index"
                },
                {
                    "name": "-n --ordered-list",
                    "content": "print lines as ordered list items\n\n--class-name=<str>\nset CSS class name prefix; omit class name if set to \"NONE\"\n",
                    "flag": "-n",
                    "long": "--ordered-list"
                },
                {
                    "name": "--inline-css",
                    "content": "output CSS within each tag (verbose output)\n",
                    "long": "--inline-css"
                },
                {
                    "name": "--enclose-pre",
                    "content": "enclose fragmented output with pre tag (assumes -f)\n\n",
                    "long": "--enclose-pre"
                }
            ]
        },
        "LATEX OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-b --babel",
                    "content": "disable Babel package shorthands\n",
                    "flag": "-b",
                    "long": "--babel"
                },
                {
                    "name": "-r --replace-quotes",
                    "content": "replace double quotes by \\dq\n",
                    "flag": "-r",
                    "long": "--replace-quotes"
                },
                {
                    "name": "--beamer",
                    "content": "adapt output for the Beamer package\n",
                    "long": "--beamer"
                },
                {
                    "name": "--pretty-symbols",
                    "content": "improve appearance of brackets and other symbols\n\n",
                    "long": "--pretty-symbols"
                }
            ]
        },
        "RTF OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "--page-color",
                    "content": "include page color attributes\n",
                    "long": "--page-color"
                },
                {
                    "name": "-x --page-size",
                    "content": "set page size, <size>=[a3, a4, a5, b4, b5, b6, letter]\n",
                    "flag": "-x",
                    "long": "--page-size"
                },
                {
                    "name": "--char-styles",
                    "content": "include character stylesheets\n\n",
                    "long": "--char-styles"
                }
            ]
        },
        "SVG OPTIONS": {
            "content": "--height=<h>\nset image height (units allowed)\n\n--width=<w>\nset image size (see --height)\n\n\nTERMINAL ESCAPE OUTPUT OPTIONS (XTERM256 OR TRUECOLOR)\n--canvas[=width]\nset background colour padding (default: 80)\n\n",
            "subsections": []
        },
        "LANGUAGE SERVER OPTIONS": {
            "content": "--ls-profile=<server>\nload LSP configuration from lsp.conf\n\n--ls-delay=<ms>\nset server initialization delay in milliseconds\n\n--ls-exec=<bin>\nset server executable name\n\n--ls-option=<option>\nset server CLI option (can be repeated)\n",
            "subsections": [
                {
                    "name": "--ls-hover",
                    "content": "execute hover requests (HTML output only)\n",
                    "long": "--ls-hover"
                },
                {
                    "name": "--ls-semantic",
                    "content": "query server for semantic token types (requires LSP 3.16)\n\n--ls-syntax=<lang>\nset syntax which is understood by the server\n",
                    "long": "--ls-semantic"
                },
                {
                    "name": "--ls-syntax-error",
                    "content": "retrieve syntax error information (assumes --ls-hover or --ls-semantic)\n\n--ls-workspace=<dir>\nset workspace directory to initialize the server\n",
                    "long": "--ls-syntax-error"
                },
                {
                    "name": "--ls-legacy",
                    "content": "do not require a server capabilities response\n\n",
                    "long": "--ls-legacy"
                }
            ]
        },
        "ENV VARIABLES": {
            "content": "Highlight recognizes these variables:\n\nHIGHLIGHTDATADIR\nsets the path to highlight's configuration scripts\n\nHIGHLIGHTOPTIONS\nmay contain command line options, but no input file paths.\n\n",
            "subsections": []
        },
        "HINTS": {
            "content": "If no in- or output files are specified, stdin and stdout will be used  for  in-  or  output.\nReading from stdin can also be triggered by the '-' option.\n\nDefault output format: xterm256 or truecolor if appropriate, HTML otherwise.\n\nStyle  definitions  are  stored  in highlight.css (HTML, XHTML, SVG) or highlight.sty (LaTeX,\nTeX) if neither -c nor -I is given. For CSS, definitions are stored in  the  output  document\nheader with -I, if -f is also given there will be no style definitions.\n\nReformatting code (-F) will only work with C, C++, C# and Java input files.\n\nLSP features require absolute input paths and disable reformatting (-F).\n\n",
            "subsections": []
        },
        "BUGS": {
            "content": "Wrapping  lines with -V or -W will cause faulty highlighting of long single line comments and\ndirectives.  Using line-range might interfere with multi line syntax elements. Use with  cau‐\ntion.\n",
            "subsections": []
        },
        "FILES": {
            "content": "The  configuration  files  are stored in /usr/share/highlight/.  Language definitions, themes\nand plugins are located in subdirectories.\n\nDocumentation  files  are  stored  in  /usr/share/doc/highlight/,  configuration   files   in\n/etc/highlight/.\n\nSee README how to install own scripts in the home directory.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "Single file conversion:\n\nhighlight -o hello.html -i hello.c\n\nhighlight -o hello.html hello.c\n\nhighlight -o hello.html -S c < hello.c\n\nhighlight -S c < hello.c > hello.html\n\nNote that a file highlight.css is created in the current directory.\n\nBatch file processing:\n\nhighlight --out-format=xhtml  -B '*.cpp' -d /home/you/htmlcode/\n\nconverts  all *.cpp files in the current directory and its subdirectories to xhtml files, and\nstores the output in /home/you/htmlcode.\n\nhighlight --out-format=latex  * -d /home/you/latexcode/\n\nconverts all files to LaTeX, stored in /home/you/latexcode/.\n\nUse --quiet to improve performance of batch file processing (recommended for usage  in  shell\nscripts).\n\nUse highlight --out-format=xterm256 <yourfile> | less -R to display a source file in a termi‐\nnal.\n\nRun highlight --list-scripts=langs to see all supported syntax types.\n\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Andre Simon <as@andre-simon.de>\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "README files and http://www.andre-simon.de/.\n\nAndre Simon                                  2023-05-11                                 highlight(1)",
            "subsections": []
        }
    },
    "summary": "Highlight - a universal sourcecode to formatted text converter",
    "flags": [],
    "examples": [
        "Single file conversion:",
        "highlight -o hello.html -i hello.c",
        "highlight -o hello.html hello.c",
        "highlight -o hello.html -S c < hello.c",
        "highlight -S c < hello.c > hello.html",
        "Note that a file highlight.css is created in the current directory.",
        "Batch file processing:",
        "highlight --out-format=xhtml  -B '*.cpp' -d /home/you/htmlcode/",
        "converts  all *.cpp files in the current directory and its subdirectories to xhtml files, and",
        "stores the output in /home/you/htmlcode.",
        "highlight --out-format=latex  * -d /home/you/latexcode/",
        "converts all files to LaTeX, stored in /home/you/latexcode/.",
        "Use --quiet to improve performance of batch file processing (recommended for usage  in  shell",
        "scripts).",
        "Use highlight --out-format=xterm256 <yourfile> | less -R to display a source file in a termi‐",
        "nal.",
        "Run highlight --list-scripts=langs to see all supported syntax types."
    ],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Output syntax-highlighted source code to a variety of formats.",
        "examples": [
            {
                "description": "Produce a complete HTML document from a source code file",
                "command": "highlight {{-o|--out-format}} {{html}} {{-s|--style}} {{theme_name}} {{-S|--syntax}} {{language}} {{path/to/source_code}}"
            },
            {
                "description": "Produce an HTML fragment, suitable for inclusion in a larger document",
                "command": "highlight {{-o|--out-format}} {{html}} {{-f|--fragment}} {{-S|--syntax}} {{language}} {{source_file}}"
            },
            {
                "description": "Inline the CSS styling in every tag",
                "command": "highlight {{-o|--out-format}} {{html}} --inline-css {{-S|--syntax}} {{language}} {{source_file}}"
            },
            {
                "description": "List all supported languages, themes, or plugins",
                "command": "highlight --list-scripts {{langs|themes|plugins}}"
            },
            {
                "description": "Print a CSS stylesheet for a theme",
                "command": "highlight {{-o|--out-format}} {{html}} --print-style {{-s|--style}} {{theme_name}} {{-S|--syntax}} {{language}} --stdout"
            }
        ]
    }
}