## default is stdoutthe terminal
htmlfile=/dev/tty

while getopts t:h: opt
do
  case $opt in
      h) htmlfile=$OPTARG ;; ## output file
      t) title=$OPTARG ;;    ## title
  esac
done
shift $(( $OPTIND - 1 ))

{
    printf "%s\n" \
     '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' \
     '<html lang="en">' \
     ' <head>' \
     "  <link rel=\"stylesheet\" type=\"text/css\" href=\"main.css\"" \
     "  <title>${title:-$1}</title>" \
     ' </head>' \
     ' <body>' \
     "  <h1>${title:-$1}</h1>" \
     "<blockquote><p>"

    ## insert closing and opening paragraph tags on blank lines,
    ## and convert open brackets to &lt;
    awk '/^$/ { printf "</p>\n<p>\n"; next }
        /</ { gsub(/</,"\\&lt;") }
            {print}' "$@"

    printf "</p></blockquote>\n</body>\n</html>\n"
} > "${htmlfile}"

