summaryrefslogtreecommitdiff
path: root/hugo-pre.sh
diff options
context:
space:
mode:
Diffstat (limited to 'hugo-pre.sh')
-rwxr-xr-xhugo-pre.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/hugo-pre.sh b/hugo-pre.sh
new file mode 100755
index 0000000..cd303ec
--- /dev/null
+++ b/hugo-pre.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+name=$1
+
+extension=${name: -3}
+
+case $extension in
+ .md) pandoc -f gfm -t html ;;
+ *)
+ cat <<- EOF
+ <pre>$(cat -)</pre>
+ EOF
+ ;;
+esac
+
+prel_head="$(grep -Eo 'h=([-A-Za-z0-9.~_+]|%[A-Fa-f0-9]{2})*' <<< "$REQUEST_URI")"
+if [ $? -eq 0 ]; then
+ head=$(cut -c 3- <<< "$prel_head")
+else
+ head=$CGIT_REPO_DEFBRANCH
+fi
+
+echo "<hr/>"
+echo "<pre>"
+cloc --git "$head" --quiet --md | pandoc -f gfm -t html
+echo "</pre>"