#!/bin/sh
# ~jhs/bin/tidy_after_vi
# Called by ~jhs/src/bsd/fixes/FreeBSD/src/gen/share/mk/berklix.mk
# Calls /usr/local/bin/tidy4

yes()
	{
	# echo Calling tidy4 $*
		# Note this $* is not params passed to this file script,
		# but params passed to this procedure by caller.
	tidy4 -i -m $*
		# If there were error that tidy4 has fixed, it exits non zero,
		# that used to get passed back to berklix.mk,
		# which errored out before it could call
		#	rm -f ${.TARGET}
		# to remove the .vhtml temporary file
	exit 0
	}
no()
	{
	echo "Skipping tidy4 -i -m $*"
	}

# ---- End of procedures, start of main --------

echo "WARNING if $* ends in .m4 do NOT ANSWER YES!"

echo -n "tidy4 $* ? "
read edit
# echo EDIT is $edit
case ${edit} in
[Nn][Oo])
	no $*
	;;
[Nn])
	no $*
	;;
[Yy][Ee][Ss])
	yes $*
	;;
[Yy])
	yes $*
	;;
*)
	echo Error, Bad Answer, should be Yes or No, Assuming No.
	no
	;;
esac
# The above decides if we will fix HTML errors or not.
# Regardless f we will, or not, now show what syntax errors remains
# Remember some syntax errors dont come form the .lmth files but from macro inclided headers, eg 
# one complaint is for bgcolor="azure"
# such errors to stderr could later be grepped out
tidy4 $* > /dev/null
