summaryrefslogtreecommitdiffabout
path: root/filters
authorLars Hjemli <hjemli@gmail.com>2009-12-08 17:31:07 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2009-12-08 17:31:07 (UTC)
commit57bb4fdb8419d7c250d4c6146910df3263943951 (patch) (side-by-side diff)
tree3597910405ffaebeff892788b1726d707439a8cb /filters
parent5c34d96f7e000eb47418ac9e39dabf92b767c9f2 (diff)
parentef07ccc72da0270e9298c36046a0187dc359b0da (diff)
downloadcgit-57bb4fdb8419d7c250d4c6146910df3263943951.zip
cgit-57bb4fdb8419d7c250d4c6146910df3263943951.tar.gz
cgit-57bb4fdb8419d7c250d4c6146910df3263943951.tar.bz2
Merge branch 'master' of http://op-co.de/cgit
Diffstat (limited to 'filters') (more/less context) (show whitespace changes)
-rwxr-xr-xfilters/syntax-highlighting.sh29
1 files changed, 12 insertions, 17 deletions
diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh
index 999ad0c..6b1c576 100755
--- a/filters/syntax-highlighting.sh
+++ b/filters/syntax-highlighting.sh
@@ -1,11 +1,15 @@
#!/bin/sh
# 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.
+#
# Note: the highlight command (http://www.andre-simon.de/) uses css for syntax
# highlighting, so you'll probably want something like the following included
# in your css file (generated by highlight 2.4.8 and adapted for cgit):
#
# table.blob .num { color:#2928ff; }
# table.blob .esc { color:#ff00ff; }
@@ -17,23 +21,14 @@
# table.blob .sym { color:#000000; }
# table.blob .kwa { color:#000000; font-weight:bold; }
# table.blob .kwb { color:#830000; }
# table.blob .kwc { color:#000000; font-weight:bold; }
# table.blob .kwd { color:#010181; }
-case "$1" in
- *.c)
- highlight -f -I -X -S c
- ;;
- *.h)
- highlight -f -I -X -S c
- ;;
- *.sh)
- highlight -f -I -X -S sh
- ;;
- *.css)
- highlight -f -I -X -S css
- ;;
- *)
- highlight -f -I -X -S txt
- ;;
-esac
+# store filename and extension in local vars
+BASENAME="$1"
+EXTENSION="${BASENAME##*.}"
+
+# map Makefile and Makefile.* to .mk
+[ "${BASENAME%%.*}" == "Makefile" ] && EXTENSION=mk
+
+exec highlight --force -f -I -X -S $EXTENSION 2>/dev/null