Diffstat (limited to 'filters/syntax-highlighting.sh') (more/less context) (ignore whitespace changes)
-rwxr-xr-x | filters/syntax-highlighting.sh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh new file mode 100755 index 0000000..999ad0c --- a/dev/null +++ b/filters/syntax-highlighting.sh | |||
@@ -0,0 +1,39 @@ | |||
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 | # Note: the highlight command (http://www.andre-simon.de/) uses css for syntax | ||
7 | # highlighting, so you'll probably want something like the following included | ||
8 | # in your css file (generated by highlight 2.4.8 and adapted for cgit): | ||
9 | # | ||
10 | # table.blob .num { color:#2928ff; } | ||
11 | # table.blob .esc { color:#ff00ff; } | ||
12 | # table.blob .str { color:#ff0000; } | ||
13 | # table.blob .dstr { color:#818100; } | ||
14 | # table.blob .slc { color:#838183; font-style:italic; } | ||
15 | # table.blob .com { color:#838183; font-style:italic; } | ||
16 | # table.blob .dir { color:#008200; } | ||
17 | # table.blob .sym { color:#000000; } | ||
18 | # table.blob .kwa { color:#000000; font-weight:bold; } | ||
19 | # table.blob .kwb { color:#830000; } | ||
20 | # table.blob .kwc { color:#000000; font-weight:bold; } | ||
21 | # table.blob .kwd { color:#010181; } | ||
22 | |||
23 | case "$1" in | ||
24 | *.c) | ||
25 | highlight -f -I -X -S c | ||
26 | ;; | ||
27 | *.h) | ||
28 | highlight -f -I -X -S c | ||
29 | ;; | ||
30 | *.sh) | ||
31 | highlight -f -I -X -S sh | ||
32 | ;; | ||
33 | *.css) | ||
34 | highlight -f -I -X -S css | ||
35 | ;; | ||
36 | *) | ||
37 | highlight -f -I -X -S txt | ||
38 | ;; | ||
39 | esac | ||