summaryrefslogtreecommitdiff
path: root/files/filters/hugo-pre.sh
blob: cd303ec2d19e2b73e9f56141557a7d543a1d8bb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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>"