summaryrefslogtreecommitdiff
path: root/compile-md.sh
blob: 7b982c03f99faade908811276a1f22bdd736bbec (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
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash

set -ex

if [ $# -ne 4 ]; then
  echo "./compile-md.sh [page|blog] [title] [in.md] [out.html]"
  exit 1
fi

ptype=$1
title=$2
in=$3
out=$4

if [ $ptype == "blog" ]; then
  cat templates/blog-header.html > $out
else
  if [ $ptype == "page" ]; then
    cat templates/page-header.html > $out
  else
    echo "Missing first parameter: [page|blog]"
    exit 1
  fi
fi

pclass=$(echo "$title" | tr [:upper:] [:lower:])
sed -ie "s/PAGE_TITLE/$title/" $out # replace title
sed -ie "s/PAGE_CLASS/$pclass/" $out # replace class

markdown $in >> $out

if [ $1 == "blog" ]; then
  cat templates/blog-footer.html >> $out
else
  cat templates/page-footer.html >> $out
fi

./tidy.sh $out