]>
git.cameronkatri.com Git - cgit.git/blob - filters/syntax-highlighting.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.
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.
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
14 # Style definition file generated by highlight 2.4.8, http://www.andre-simon.de/
16 # table.blob .num { color:#2928ff; }
17 # table.blob .esc { color:#ff00ff; }
18 # table.blob .str { color:#ff0000; }
19 # table.blob .dstr { color:#818100; }
20 # table.blob .slc { color:#838183; font-style:italic; }
21 # table.blob .com { color:#838183; font-style:italic; }
22 # table.blob .dir { color:#008200; }
23 # table.blob .sym { color:#000000; }
24 # table.blob .kwa { color:#000000; font-weight:bold; }
25 # table.blob .kwb { color:#830000; }
26 # table.blob .kwc { color:#000000; font-weight:bold; }
27 # table.blob .kwd { color:#010181; }
30 # Style definition file generated by highlight 2.6.14, http://www.andre-simon.de/
32 # body.hl { background-color:#ffffff; }
33 # pre.hl { color:#000000; background-color:#ffffff; font-size:10pt; font-family:'Courier New';}
34 # .hl.num { color:#2928ff; }
35 # .hl.esc { color:#ff00ff; }
36 # .hl.str { color:#ff0000; }
37 # .hl.dstr { color:#818100; }
38 # .hl.slc { color:#838183; font-style:italic; }
39 # .hl.com { color:#838183; font-style:italic; }
40 # .hl.dir { color:#008200; }
41 # .hl.sym { color:#000000; }
42 # .hl.line { color:#555555; }
43 # .hl.mark { background-color:#ffffbb;}
44 # .hl.kwa { color:#000000; font-weight:bold; }
45 # .hl.kwb { color:#830000; }
46 # .hl.kwc { color:#000000; font-weight:bold; }
47 # .hl.kwd { color:#010181; }
50 # Style definition file generated by highlight 3.8, http://www.andre-simon.de/
52 # body.hl { background-color:#e0eaee; }
53 # pre.hl { color:#000000; background-color:#e0eaee; font-size:10pt; font-family:'Courier New';}
54 # .hl.num { color:#b07e00; }
55 # .hl.esc { color:#ff00ff; }
56 # .hl.str { color:#bf0303; }
57 # .hl.pps { color:#818100; }
58 # .hl.slc { color:#838183; font-style:italic; }
59 # .hl.com { color:#838183; font-style:italic; }
60 # .hl.ppc { color:#008200; }
61 # .hl.opt { color:#000000; }
62 # .hl.lin { color:#555555; }
63 # .hl.kwa { color:#000000; font-weight:bold; }
64 # .hl.kwb { color:#0057ae; }
65 # .hl.kwc { color:#000000; font-weight:bold; }
66 # .hl.kwd { color:#010181; }
69 # Style definition file generated by highlight 3.13, http://www.andre-simon.de/
71 # body.hl { background-color:#e0eaee; }
72 # pre.hl { color:#000000; background-color:#e0eaee; font-size:10pt; font-family:'Courier New',monospace;}
73 # .hl.num { color:#b07e00; }
74 # .hl.esc { color:#ff00ff; }
75 # .hl.str { color:#bf0303; }
76 # .hl.pps { color:#818100; }
77 # .hl.slc { color:#838183; font-style:italic; }
78 # .hl.com { color:#838183; font-style:italic; }
79 # .hl.ppc { color:#008200; }
80 # .hl.opt { color:#000000; }
81 # .hl.ipl { color:#0057ae; }
82 # .hl.lin { color:#555555; }
83 # .hl.kwa { color:#000000; font-weight:bold; }
84 # .hl.kwb { color:#0057ae; }
85 # .hl.kwc { color:#000000; font-weight:bold; }
86 # .hl.kwd { color:#010181; }
89 # The following environment variables can be used to retrieve the configuration
90 # of the repository for which this script is called:
91 # CGIT_REPO_URL ( = repo.url setting )
92 # CGIT_REPO_NAME ( = repo.name setting )
93 # CGIT_REPO_PATH ( = repo.path setting )
94 # CGIT_REPO_OWNER ( = repo.owner setting )
95 # CGIT_REPO_DEFBRANCH ( = repo.defbranch setting )
96 # CGIT_REPO_SECTION ( = section setting )
97 # CGIT_REPO_CLONE_URL ( = repo.clone-url setting )
100 # store filename and extension in local vars
102 EXTENSION
="${BASENAME##*.}"
104 [ "${BASENAME}" = "${EXTENSION}" ] && EXTENSION
=txt
105 [ -z "${EXTENSION}" ] && EXTENSION
=txt
107 # map Makefile and Makefile.* to .mk
108 [ "${BASENAME%%.*}" = "Makefile" ] && EXTENSION
=mk
110 # highlight versions 2 and 3 have different commandline options. Specifically,
111 # the -X option that is used for version 2 is replaced by the -O xhtml option
114 # Version 2 can be found (for example) on EPEL 5, while version 3 can be
115 # found (for example) on EPEL 6.
117 # This is for version 2
118 exec highlight
--force -f -I -X -S "$EXTENSION" 2>/dev
/null
120 # This is for version 3
121 #exec highlight --force -f -I -O xhtml -S "$EXTENSION" 2>/dev/null