#!/bin/bash
# The script will export the document to an self-contained HTML,
# unless it's given a template name from the 'templates' folder
# For example: ./export.sh OSM_White_Paper_Template_body_fixed.docx

template=${1}
timestamp=$(date "+%Y.%m.%d-%H.%M.%S")
documents="00-introduction.md 01-requirements.md 02-day0.md \
03-day1.md 04-day2.md 05-basic-examples.md 06-walkthrough.md"

if [ -z "$template" ]; then
name=output-$timestamp.html
echo "No DOCX template was given, exporting to HTML"
pandoc --toc -c assets/normalize.css -s $documents --metadata pagetitle='VNF Onboarding Guidelines'\
 -o $name
echo "File was exported to ./${name}"
else
name=output-$timestamp.docx
echo "The following DOCX template will be used: ${template}"
pandoc -f markdown --filter=pandoc-docx-pagebreakpy $documents --extract-media=./assets --reference-doc=templates/$template \
-o outputs/$name
echo "File was exported to ./outputs/${name}"
fi

