render () {
InPath="$1"
InFile="${InPath##*/}"
InFileExt="${InPath##*.}"
InBase="${InFile%.*}"
InDir="${InPath%/*}"
if [ "$InDir" = "$InPath" ] ; then
InDir="."
fi
OutPath="$2"
OutFile="${OutPath##*/}"
OutBase="${OutFile%.*}"
OutDir="${OutPath%/*}"
if [ "$OutDir" = "$OutPath" ] ; then
OutDir="."
fi
mkdir -p "$OutDir"
cp -r -L "$InDir/assets/" "$OutDir"
cp "$InDir/web.css" "$OutDir"
cp "$InPath" "$OutDir"
CssPath="web.css"
HtmlPath="$OutBase.html"
cd "$OutDir"
pandoc -s --to=html --from=markdown+yaml_metadata_block \
--toc --number-sections -H "$CssPath" \
-o "$HtmlPath" "$InFile"
rm "$InFile"
}
if [[ -n "${2/[ ]*\n/}" ]] ; then
OutPath="$2"
else
OutPath="${1%.*}.html" fi
render "$1" "$OutPath"