#!/bin/sh

source=README.md
target=README.html
title="backup2l: README"

if test ! -e ${source}
then
    echo "Please add file ${source} into the current directory!"
    exit 1
fi

if test -x /usr/bin/pandoc
then

    echo "Converting ..."
    pandoc --quiet \
        -r markdown -w html \
        --title-prefix="XXTITELXX" \
        --email-obfuscation=references \
        --standalone   ${source}  |\
      sed "s#XXTITELXX...#${title}#" |\
      sed "s#line-height: 1.5#line-height: 1.35#" |\
      sed "s#font-size: 20px#font-size: 18px#" |\
      sed "s#max-width: 36em#max-width: 42em#" |\
      sed "s#max-width: 600px#max-width: 720px#" |\
      sed "s#font-size: 85%#font-size: 75%#" |\
      sed "s#overflow: auto#overflow: auto;\n      line-height: 1.15#" >${target}

    sleep 0.4
    echo "${source} converted to ${target}."

else
    echo "Please install the tool pandoc - Abort!"
    exit 1
fi
