#! /bin/ksh

#
# Name        : ${HOME}/bin/convert2html.ksh
#
# Version     : 1.0
#
# Author      : Gerard van Wageningen
#
# Description : Use Gvim to generate a syntax highlighted HTML file
#
# 1.0   First Version
#

\whence set_debug 1>/dev/null 2>&1 && eval $( set_debug ${0##*/} )

typeset FileType=''

if [[ ! -r "$1" ]]
then
  print -u2 "Can not read file $1, bailing out."
  exit 1
fi

if ! whence -p gvim 1>/dev/null 2>&1 
then
  print -u2 "Can not find executable gvim, bailing out."
  exit 1
fi

case "$1" in
  *.dms|*.par.template) FileType='+set\ ft=rexx' ;;
  *.ksh) FileType='+set\ ft=sh' ;;
  *) ;;
esac

gvim -f "$1" +'syntax on' ${FileType} +'runtime syntax/2html.vim' +"w! $1.html" +'qa!'

exit $?

################### EOF ###################
