From c795d76a19aee2f3f7f8a32e9f66a111f348a887 Mon Sep 17 00:00:00 2001 From: Prefetch Date: Mon, 24 Jul 2023 21:33:11 +0200 Subject: Add cgit config --- cgit/syntax-highlighting.dash | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 cgit/syntax-highlighting.dash (limited to 'cgit/syntax-highlighting.dash') diff --git a/cgit/syntax-highlighting.dash b/cgit/syntax-highlighting.dash new file mode 100755 index 0000000..9db14f9 --- /dev/null +++ b/cgit/syntax-highlighting.dash @@ -0,0 +1,28 @@ +#!/usr/bin/dash + +# This script requires a shell supporting the ${var##pattern} syntax. +# It is supported by at least dash and bash, however not by busybox. +# +# The following environment variables can be used to retrieve the +# configuration of the repository for which this script is called: +# CGIT_REPO_URL ( = repo.url setting ) +# CGIT_REPO_NAME ( = repo.name setting ) +# CGIT_REPO_PATH ( = repo.path setting ) +# CGIT_REPO_OWNER ( = repo.owner setting ) +# CGIT_REPO_DEFBRANCH ( = repo.defbranch setting ) +# CGIT_REPO_SECTION ( = section setting ) +# CGIT_REPO_CLONE_URL ( = repo.clone-url setting ) + +# Store filename and extension in local variables +BASENAME="$1" +EXTENSION="${BASENAME##*.}" + +# Use .txt as a sensible default format +[ "${BASENAME}" = "${EXTENSION}" ] && EXTENSION=txt +[ -z "${EXTENSION}" ] && EXTENSION=txt + +# Map Makefile and Makefile.* to .mk +[ "${BASENAME%%.*}" = "Makefile" ] && EXTENSION=mk + +# This is for version 3 and above of the "highlight" package +exec highlight --force -f -I -O xhtml -S "$EXTENSION" 2>/dev/null -- cgit v1.2.3