The syntax highlighting option in a cgit installation is no working properly and I want to see if it will run properly from the command line if all the necessary parameters are present.

The option in /etc/cgitrc is correctly set.


When I ran the highlight command on a bash file for instance the css and span classes are in the output, but when I run /usr/lib/cgit/filters/syntax-highlighting.sh on the file the css and span tags don't show.

The command actual highlight command in the script (the last line) is

exec highlight --force --inline-css -f -I -O xhtml -S "$EXTENSION" 2>/dev/null
# This script can be used to implement syntax highlighting in the cgit
# tree-view by refering to this file with the source-filter or repo.source-
# filter options in cgitrc.
# This script requires a shell supporting the ${var##pattern} syntax.
# It is supported by at least dash and bash, however busybox environments
# might have to use an external call to sed instead.

# Code considered irrelevant snipped

# store filename and extension in local vars

[ -z "${EXTENSION}" ] && EXTENSION=txt

# map Makefile and Makefile.* to .mk
[ "${BASENAME%%.*}" = "Makefile" ] && EXTENSION=mk

# highlight versions 2 and 3 have different commandline options. Specifically,
# the -X option that is used for version 2 is replaced by the -O xhtml option
# for version 3.
# Version 2 can be found (for example) on EPEL 5, while version 3 can be
# found (for example) on EPEL 6.
# This is for version 2
#exec highlight --force -f -I -X -S "$EXTENSION" 2>/dev/null

# This is for version 3
exec highlight --force --inline-css -f -I -O xhtml -S "$EXTENSION" 2>/dev/null

1 Answer 1


It turns out that in order to get syntax highlighting working under cgit, the line specifying syntax highlighting must appear before the line for the repo locations. In the example given below, syntax highlighting will fail if the source-filter line is placed after the include line.


I checked and unless it is documented somewhere it must be a bug. Perhaps some design issue requires to be that way.

More info at https://wiki.archlinux.org/index.php/Cgit

  • 1
    I checked now more thouroughly and it seems like enable-commit-graph, enable-blame, enable-log-filecount, readme must also be specified berfore scan-path, in my case. My suspicion is, that the repo analysis functionality of cgit is being triggered by include or scan-path and that behaviour is modified by the config options we are talking about. If we specify them after the repos have been scanned, they have no langer any effect. I will look at the sources to confirm my suspicion.
    – sschober
    Commented May 20 at 5:55
  • 1
    Looked at the sources and it is like I suspected: the repo scanning is being trigger during argument parsing (see here). The same seems to be true for include (see here)
    – sschober
    Commented May 20 at 6:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .