#!/bin/zsh

# !TEX-htmlPreview

OUTFILE="`basename "$1"`"

EXTENSION="${OUTFILE##*.}"

if [[ "$EXTENSION" = "tex" ]]; then
	echo "Cannot typeset file with extension .tex"
	exit
fi

if  [[ "$EXTENSION" = "ctx" ]]; then
	echo "Cannot typeset file with extension .ctx"
	exit
fi

if  [[ "$EXTENSION" = "ltx" ]]; then
	echo "Cannot typeset file with extension .ltx"
	exit
fi

xsltproc  -xinclude $HOME/Documents/mathbook/xsl/pretext-html.xsl "$1" 

# test for successful tranlation
if [ ${?} -ne 0 ]; then
	echo ""
	echo "Translation to HTML failed. Please use the PreTeXt-Validate engine to check your file."
	exit
fi
# end of test for successful translation

