summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/highlight/filetypes.conf2
-rwxr-xr-xusr/lib/cgit/filters/syntax-highlighting-edited.sh27
2 files changed, 11 insertions, 18 deletions
diff --git a/etc/highlight/filetypes.conf b/etc/highlight/filetypes.conf
index f0715918..74b9c938 100644
--- a/etc/highlight/filetypes.conf
+++ b/etc/highlight/filetypes.conf
@@ -63,7 +63,7 @@ FileMapping = {
{ Lang="gdscript", Extensions={"gd"} },
{ Lang="haskell", Extensions={"hs"} },
{ Lang="hugo", Extensions={"hug"} },
- { Lang="ini", Extensions={"doxyfile", "desktop", "kdev3", "reg", "cfg", "inf"} },
+ { Lang="ini", Extensions={"doxyfile", "desktop", "kdev3", "reg", "cfg", "inf", "hook"} },
{ Lang="jam", Extensions={"jam", "ham"} },
{ Lang="java", Extensions={"groovy", "grv", "jenkinsfile", "gradle"} },
{ Lang="javascript", Extensions={"js"} },
diff --git a/usr/lib/cgit/filters/syntax-highlighting-edited.sh b/usr/lib/cgit/filters/syntax-highlighting-edited.sh
index 3de95fa5..2c33b907 100755
--- a/usr/lib/cgit/filters/syntax-highlighting-edited.sh
+++ b/usr/lib/cgit/filters/syntax-highlighting-edited.sh
@@ -101,21 +101,14 @@
BASENAME="$1"
EXTENSION="${BASENAME##*.}"
-[ "${BASENAME}" = "${EXTENSION}" ] && EXTENSION=txt
-[ -z "${EXTENSION}" ] && EXTENSION=txt
+# map Makefile, Makefile.*, makefile, and makefile.* to .mk
+if [ "${BASENAME%%.*}" = Makefile ] || [ "${BASENAME%%.*}" = makefile ]; then
+ EXTENSION=mk
+fi
-# map Makefile and Makefile.* to .mk
-[ "${BASENAME%%.*}" = "Makefile" ] && EXTENSION=mk
-
-# highlight versions 2 and 3 have different commandline options. Specifically,
-# the -X option that is used for version 2 is replaced by the -O xhtml option
-# for version 3.
-#
-# Version 2 can be found (for example) on EPEL 5, while version 3 can be
-# found (for example) on EPEL 6.
-#
-# This is for version 2
-#exec highlight --force -f -I -X -S "$EXTENSION" 2>/dev/null
-
-# This is for version 3
-exec highlight --force --inline-css -f -I -O xhtml -S "$EXTENSION" 2>/dev/null
+# `--force` needed for highlight; one example is `cat 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
+else
+ exec highlight --force --inline-css -f -I -O xhtml -S "$EXTENSION" 2>/dev/null
+fi