all repos — cgit @ v0.9.0.3

a hyperfast web frontend for git written in c

filters/syntax-highlighting.sh (view raw)

 1#!/bin/sh
 2# This script can be used to implement syntax highlighting in the cgit
 3# tree-view by refering to this file with the source-filter or repo.source-
 4# filter options in cgitrc.
 5#
 6# This script requires a shell supporting the ${var##pattern} syntax.
 7# It is supported by at least dash and bash, however busybox environments
 8# might have to use an external call to sed instead.
 9#
10# Note: the highlight command (http://www.andre-simon.de/) uses css for syntax
11# highlighting, so you'll probably want something like the following included
12# in your css file (generated by highlight 2.4.8 and adapted for cgit):
13#
14# table.blob .num  { color:#2928ff; }
15# table.blob .esc  { color:#ff00ff; }
16# table.blob .str  { color:#ff0000; }
17# table.blob .dstr { color:#818100; }
18# table.blob .slc  { color:#838183; font-style:italic; }
19# table.blob .com  { color:#838183; font-style:italic; }
20# table.blob .dir  { color:#008200; }
21# table.blob .sym  { color:#000000; }
22# table.blob .kwa  { color:#000000; font-weight:bold; }
23# table.blob .kwb  { color:#830000; }
24# table.blob .kwc  { color:#000000; font-weight:bold; }
25# table.blob .kwd  { color:#010181; }
26
27# store filename and extension in local vars
28BASENAME="$1"
29EXTENSION="${BASENAME##*.}"
30
31# map Makefile and Makefile.* to .mk
32[ "${BASENAME%%.*}" == "Makefile" ] && EXTENSION=mk
33
34exec highlight --force -f -I -X -S $EXTENSION 2>/dev/null