#!/bin/bash

if [ -z "$1" ]; then
  echo usage: $0 [filename.md]
  exit 1
fi

base=`basename -s .md $1`
filename="$base.html"

cat > ./$filename <<header
<html>
<head>
<title>$base</title>
<style type="text/css">
body {
  margin:40px auto;
  max-width:650px;
  line-height:1.6;
  font-size:18px;
  color:#444;
  background-color:#eee;
  padding:0 10px;
}

h1,h2,h3 {
  line-height:1.2;
}
h1 > a, h2 > a, h3 > a {
  color: #444;
  text-decoration: none;
}
img {
  max-width: 650px;
}
</style>
</head>
<body>
header

markdown $1 >> ./$filename

cat >> ./$filename <<footer
</body>
</html>
footer
