#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG  				#
#							#
# Licensed under GNU GENERAL PUBLIC LICENSE v3    	#
#							#
# Copyright 2007 - 2017 Christopher Bratusek		#
#							#
#########################################################

if ! which xmlindent &>/dev/null; then
	echo -e "xmlindent not found, xmlpager won't work."
	exit 1
fi

case ${1} in

	-h | --help )
		bashstyle-help -a "hackerb9" -e "" -h "http://www.commandlinefu.com/"\
			-l "GNU GPL v3" -n "xmlpager" -s "pager for xml files with highlighted text"\
			-v "${BSNG_VERSION}" -y "${BSNG_YEAR}"\
			-o "file:|xml file to read"
	;;

	*)
		xmlindent "${@}" | \
			awk '{gsub(">",">'$(tput bold; tput setf 4)'"); gsub("<","'$(tput sgr0)'<"); print;} END {print "'$(tput sgr0)'"}' | \
			less -r
	;;

esac
