diff options
author | Prefetch | 2023-07-24 21:33:11 +0200 |
---|---|---|
committer | Prefetch | 2023-07-24 21:33:11 +0200 |
commit | c795d76a19aee2f3f7f8a32e9f66a111f348a887 (patch) | |
tree | a9ab40db412ac51fc5f49f1139ba3a68d7b87129 /cgit/syntax-highlighting.dash | |
parent | bc337e0d7dfc035068202bba67e1b3898f54db02 (diff) |
Add cgit config
Diffstat (limited to 'cgit/syntax-highlighting.dash')
-rwxr-xr-x | cgit/syntax-highlighting.dash | 28 |
1 files changed, 28 insertions, 0 deletions
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 |