diff options
Diffstat (limited to 'usr')
-rwxr-xr-x | usr/lib/cgit/filters/syntax-highlighting-edited.sh | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/usr/lib/cgit/filters/syntax-highlighting-edited.sh b/usr/lib/cgit/filters/syntax-highlighting-edited.sh index 81e39197..3fe4ab41 100755 --- a/usr/lib/cgit/filters/syntax-highlighting-edited.sh +++ b/usr/lib/cgit/filters/syntax-highlighting-edited.sh @@ -97,18 +97,17 @@ # CGIT_REPO_CLONE_URL ( = repo.clone-url setting ) # -# store filename and extension in local vars -BASENAME="$1" -EXTENSION="${BASENAME##*.}" - -# map Makefile, Makefile.*, makefile, and makefile.* to .mk -if [ "${BASENAME%%.*}" = Makefile ] || [ "${BASENAME%%.*}" = makefile ]; then - EXTENSION=mk -fi +syntax= +case "$1" in + nginx.conf) syntax=nginx;; + pacman.conf) syntax=ini;; + cgitrc) syntax=ini;; + .gitolite.rc) syntax=perl;; +esac # `--force` needed for highlight; one example is `< textfile highlight -O ansi --force`, without `--force` will error 1 and no output -if [ "${BASENAME}" = "${EXTENSION}" ] || [ -z "${EXTENSION}" ]; then - exec highlight --force --inline-css -f -I -O xhtml 2>/dev/null +if [ "$syntax_type" ]; then + exec highlight --force --inline-css -f -I -O xhtml -S "$syntax" 2>/dev/null else - exec highlight --force --inline-css -f -I -O xhtml -S "$EXTENSION" 2>/dev/null + exec highlight --force --inline-css -f -I -O xhtml --syntax-by-name "$1" 2>/dev/null fi |