summaryrefslogtreecommitdiff
path: root/opt
diff options
context:
space:
mode:
authorLambda <lambda@disroot.org>2025-12-10 15:19:24 -0500
committerLambda <lambda@disroot.org>2025-12-10 15:19:24 -0500
commit0c79ff01fe7eb5abf369e4c14edf8eeadb692c3b (patch)
tree36aed08de5add804cacb8286ef0768381ffa5b4a /opt
downloadcgit-docker-0c79ff01fe7eb5abf369e4c14edf8eeadb692c3b.tar.gz
cgit-docker-0c79ff01fe7eb5abf369e4c14edf8eeadb692c3b.tar.bz2
cgit-docker-0c79ff01fe7eb5abf369e4c14edf8eeadb692c3b.zip
Initial commit
Diffstat (limited to 'opt')
-rw-r--r--opt/highlight.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/opt/highlight.sh b/opt/highlight.sh
new file mode 100644
index 0000000..13e8ae6
--- /dev/null
+++ b/opt/highlight.sh
@@ -0,0 +1,23 @@
+## This is for syntax highlighting
+# Get the name of the file and the extension of it
+BASENAME="$1"
+EXTENSION="${BASENAME##*.}"
+
+[ "${BASENAME}" = "${EXTENSION}" ] && EXTENSION=txt
+[ -z "${EXTENSION}" ] && EXTENSION=txt
+
+# Makefile and Makefile.* are all .mk
+[ "${BASENAME%%.*}" = "Makefile" ] && EXTENSION=mk
+
+# User note: highlight v2 and v3 have different command options
+# -X is replaced by "-O xhtml" in v3
+
+# If for whatever reason, this container is using EPEL5 (it shouldn't),
+# use the following line instead of the bottom line
+# exec highlight --force -f -I -X -S "$EXTENSION" 2>/dev/null
+
+# EPEL6 version with no inline css
+# exec highlight --force -f -I -O xhtml -S "EXTENSION" 2>/dev/null
+
+# highlight v3 is available on EPEL6
+exec highlight --force --inline-css -f -I -O xhtml -S "EXTENSION" 2>/dev/null \ No newline at end of file