homepage/tmpl/mdwntohtml

53 lines
1.1 KiB
Bash
Executable File

#! /bin/sh
cat <<EOD
<!DOCTYPE html>
<html lang="en">
<head>
EOD
while IFS=': ' read field value; do
case "$field" in
"")
break
;;
Title)
# echo strips leading and trailing whitespace
title=$value
;;
Header)
printf " %s\n" "$value"
;;
Time-stamp)
timestamp=$(printf "%s" "$value" | awk -F '[< ]' '{print $2}')
;;
esac
done
tmpl=$(dirname $0)
cat <<EOF
<title>$title</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="/neale/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="/neale/css/default.css">
<link rel="stylesheet" type="text/css" media="print" href="/neale/css/print.css">
<link rel="icon" type="image/png" href="/neale/face.png">
</head>
<body>
<h1>$title</h1>
EOF
cat $tmpl/head.tmpl
pandoc -f markdown -t html5
[ -n "$timestamp" ] && cat <<EOF
<p id="timestamp">Last modified: $timestamp</p>
EOF
cat $tmpl/foot.tmpl
cat <<EOF
</body>
</html>
EOF