summaryrefslogtreecommitdiff
path: root/hugo-pre.sh
blob: dfc4a9a45862385946e23067473b7cee3d9cac05 (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
#!/bin/bash

name=$1

case $name in
	*.md) pandoc -f gfm -t html ;;
	*.wiki) pandoc -f vimwiki -t html --table-of-contents
	*)
		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>"