#!/bin/sh
processline()
{
	echo "- $1 -"
	name="$1"
	# I changed "0" to "$" because my sed
	# doesn't want to understand "0".
	# -- Zoltan
	cat xaos.hlp | sed '1,/%'"$1"'/d;/^%/,$ d' | sed \
'1,2s_<head>\([^<]*\)</head>_<!-- X-URL: http://xaos.sf.net/help/'"$1"' -->\
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\
<HTML>\
<HEAD>\
  <LINK rev=made href="mailto:jh@ucw.cz">\
  <META name="description" content="XaoS online help '"$1"'>\
  <META name="keywords" content="XaoS, realtime, fractal, zoomer">\
  <TITLE>XaoS online help - \1</TITLE>\
</HEAD>\
<BODY BGCOLOR="#ffffff" TEXT="#594941">\
<CENTER><A HREF="main.html"><IMG BORDER=0 ALT="XaoS online help" SRC="help.jpg"></A>\
<H1><A NAME="body">\1</A></H1></CENTER>\
_g
s_<head>_<center><H2>_g
s_</head>_</H2></center>_g
s_<emph>_<strong>_g
s_<submenu>__g
s_<menuhead>__g
s_</menuhead>__g
s_<mainmenu>__g
s_<menuitems>__g
s_<notex>__g
s_</notex>__g
s_<node.*>__g
s_</emph>_</strong>_g
s_<tt>_<code>_g
s_</tt>_</code>_g
s_<tutor [^>]*>_<i>_g
s_</tutor>_</i>_g
s_<a \([^>]*\)>_<A HREF="\1.html#body">_g
s/'\'\''/"/g
s/``/"/g' > $1.html
	echo "</BODY></HTML>" >> $1.html
	shift
	while [ "$1" != "" ] ; do
	  echo Link "$1" "$name"
	  if [ "$1" != "$name" ] ; then
	    ln -sf $name.html $1.html 
	  fi
	  shift
	done
}
process()
{
	while read line ; do
		eval "processline $line"
	done
}
grep "^%" xaos.hlp | sed '/%%/d;s/%//g' | process
rm -f index.html
ln -s main.html index.html
