#!/usr/local/bin/perl
#$homesrc=$ENV{'HOME'} . "/.sliderc";

$face="FACE=ARIAL";
$src=".htxprc";
$envfile="env.o";

#-------------------------------------------------------------------
# Procedure Definitions
#-------------------------------------------------------------------
sub escapesmbl {
$_[0] =~ s/&pipe;/|/g;
$_[0] =~ s/˙/./g;
}

#-------------------------------------------------------------------
# Get .htxprc from . upward to $HOME and append to .env
#-------------------------------------------------------------------

@SRC=`rfind $src`;
open(ENVFILE, ">> $envfile");
foreach $i ( @SRC ) {
open (TMP, "< $i");
while (<TMP>) { print ENVFILE; }
close TMP;
}
close (ENVFILE);

#-----------------------------------------------
# Default parameters
#-----------------------------------------------
$TScolor0="#33ffcc" ;
$TScolor2=pink;
$codecolor0=turquoise;
$codesize0=5;
$TSsize0=5;

#-----------------------------------------------
# Process things in env.o
# take care environmental instructions: .define
#-----------------------------------------------

open (ENVFILE, "< $envfile");
while (<ENVFILE> ) {
if ( $_ =~ /^\.define\s+(\S+)\s(.+$)/ ) {
$macroarray{$1} = $2;
next;
}
}
close (ENVFILE);

#-----------------------------------------------
# Strat to process input files
#-----------------------------------------------
while (<> ) {

#-----------------------------------------------
# scan for define to record and defined words to expand
#-----------------------------------------------

if ( $_ =~ /^\.define\s+(\S+)\s(.+$)/ ) {
$macroarray{$1} = $2;
#print "found a macro definition: \n";
next;
}
else {
foreach $key ( keys %macroarray ) {
if ( $_ =~ s/$key/$macroarray{$key}/g) {
next;
}
}
}

#==========================================================
# Started from the beginning of the line and take 0 argument
#==========================================================

$_ =~ s|^(\s*)\.\s(\s*)|$1<li>$2|;
$_ =~ s|^\./\s|</li> |;
$_ =~ s|^\.-\s|<hr>|;

$_ =~ s|\.body\s|<HTML><body bgcolor="#ffffcc" TEXT="#330066" LINK="red" VLINK="green" ALINK="#000000">|;
$_ =~ s|^\.main\s|<a name="main"></a>|;
$_ =~ s|^\.main_e\s|<a name="main_e"></a>|;
$_ =~ s|^\.back\s|<a href="#main">¦^¥Dµe­±</a>|;
$_ =~ s|^\.back_e\s|<a href="#main_e">BACK_TO_MAIN_PAGE</a>|;
$_ =~ s|^\.Form|</FORM>|;
$_ =~ s|^\.Textarea|</TEXTAREA>|;
$_ =~ s|^\.Select|</SELECT>|;

#$_ =~ s|^\.submit|<INPUT TYPE="SUBMIT" VALUE="Submit">\n |;
#$_ =~ s|^\.reset|<INPUT TYPE="RESET" VALUE="Reset">\n |;
#$_ =~ s|^\.h1\s|<h1>|;
#$_ =~ s|^\.H1\s|</h1>|;
#$_ =~ s|^\.h2\s|<h2>|;
#$_ =~ s|^\.H2\s|</h2>|;
#$_ =~ s|^\.h3\s|<h3>|;
#$_ =~ s|^\.H3\s|</h3>|;
#$_ =~ s|^\.h4\s|<h4>|;
#$_ =~ s|^\.H4\s|</h4>|;
#$_ =~ s|^\.h5\s|<h5>|;
#$_ =~ s|^\.H5\s|</h5>|;
#$_ =~ s|^\.h6\s|<h6>|;
#$_ =~ s|^\.H6\s|</h6>|;

$_ =~ s|\.blk\s|<blink> |g;
$_ =~ s|\.Blk\s|</blink> |g;
$_ =~ s|^\.br\s|<br> |;
$_ =~ s|^\.o\s|<ol> |;
$_ =~ s|^\.O\s|</ol>|;
$_ =~ s|^\.p\s|<p> |;
$_ =~ s|^\.u\s|<ul> |;

$_ =~ s|^\.U\s|</ul>|;
$_ =~ s|^\.C\s|</center>|;
$_ =~ s|\.bk\s|  |g;


#==========================================================
# Code Segments, a block of preformated text
#==========================================================

$_ =~ s|\.code0\s|<center><table border=2 bgcolor=#00CC99> <tr><th align=left><font size=5 $face>|g;
$_ =~ s|\.Code0\s|</table></center> |g;

if ( $_ =~ /^\.code/ ) {
@F = split (' ');
$codecolor = ( $F[1] == -1 || $F[1] eq "" ) ? $codecolor0 : $F[1] ;
$codesize = ( $F[2] eq "" ) ? $codesize0 : $F[2] ;
$_ = "<center><table border=2 bgcolor=$codecolor> <tr><th align=left><pre><font size=$codesize $face>";
}
$_ =~ s|^\.Code|</pre></table></center> |g;


#==========================================================
# TextArea, submit, reset in Form
#==========================================================
if ( $_ =~ /^\s*\.textarea/ ) {
$_ =~ s/^\s*//;
@F = split (' ');
$textrow = ( $F[2] ne '') ? $F[2] : 10 ;
$textcol = ( $F[3] ne '') ? $F[3] : 70 ;
$_ = "<TEXTAREA name=$F[1] ROWS=$textrow COLS=$textcol>\n";
}

if ( $_ =~ /^\s*\.submit/ ) {
$_ =~ s/^\s*//;
@F = split (' ');
$value = ( $F[1] ne '') ? $F[1] : "Submit" ;
$_ = "<Input TYPE=SUBMIT VALUE=$value>\n";
}

if ( $_ =~ /^\s*\.reset/ ) {
$_ =~ s/^\s*//;
@F = split (' ');
$value = ( $F[1] ne '') ? $F[1] : "Reset" ;
$_ = "<Input TYPE=RESET VALUE=$value>\n";
}

#==========================================================
# Math
#==========================================================

$_ =~ s|\.sup\s+(\S+)|<sup> $1 </sup>|g;
$_ =~ s|\.sub\s+(\S+)|<sub> $1 </sub>|g;

$_ =~ s|\.alpha\s|<font face=symbol>a</font>|g;
$_ =~ s|\.beta\s|<font face=symbol>b</font>|g;
$_ =~ s|\.chi\s|<font face=symbol>c</font>|g;
$_ =~ s|\.delta\s|<font face=symbol>d</font>|g;
$_ =~ s|\.epsilon\s|<font face=symbol>e</font>|g;
$_ =~ s|\.eta\s|<font face=symbol>h</font>|g;
$_ =~ s|\.gamma\s|<font face=symbol>g</font>|g;
$_ =~ s|\.iota\s|<font face=symbol>i</font>|g;
$_ =~ s|\.kappa\s|<font face=symbol>k</font>|g;
$_ =~ s|\.lambda\s|<font face=symbol>l</font>|g;
$_ =~ s|\.mu\s|<font face=symbol>m</font>|g;
$_ =~ s|\.nu\s|<font face=symbol>n</font>|g;
$_ =~ s|\.omega\s|<font face=symbol>w</font>|g;
$_ =~ s|\.omicron\s|<font face=symbol>o</font>|g;
$_ =~ s|\.phi\s|<font face=symbol>f</font>|g;
$_ =~ s|\.pi\s|<font face=symbol>p</font>|g;
$_ =~ s|\.project\s|<font face=symbol size=7>p</font>|g;
$_ =~ s|\.psi\s|<font face=symbol>y</font>|g;
$_ =~ s|\.rho\s|<font face=symbol>r</font>|g;
$_ =~ s|\.sigma\s|<font face=symbol>s</font>|g;
$_ =~ s|\.dbselect\s|<font face=symbol size=7>s</font>|g;
$_ =~ s|\.tau\s|<font face=symbol>t</font>|g;
$_ =~ s|\.theta\s|<font face=symbol>q</font>|g;
$_ =~ s|\.upsilon\s|<font face=symbol>u</font>|g;
$_ =~ s|\.xi\s|<font face=symbol>x</font>|g;
$_ =~ s|\.zeta\s|<font face=symbol>z</font>|g;

$_ =~ s|\.DELTA|<font face=symbol>D</font>|g;
$_ =~ s|\.GAMMA|<font face=symbol>G</font>|g;
$_ =~ s|\.LAMBDA|<font face=symbol>L</font>|g;
$_ =~ s|\.OMEGA|<font face=symbol>W</font>|g;
$_ =~ s|\.PHI|<font face=symbol>F</font>|g;
$_ =~ s|\.PI|<font face=symbol>P</font>|g;
$_ =~ s|\.PSI|<font face=symbol>Y</font>|g;
$_ =~ s|\.SIGMA|<font face=symbol>S</font>|g;
$_ =~ s|\.TAU|<font face=symbol>T</font>|g;
$_ =~ s|\.THETA|<font face=symbol>Q</font>|g;
$_ =~ s|\.UPSILON|<font face=symbol>U</font>|g;
$_ =~ s|\.XI|<font face=symbol>X</font>|g;
$_ =~ s|\.ZETA|<font face=symbol>Z</font>|g;


#==========================================================
# Tables
#==========================================================

if ( ( $_ =~ /^\.TS/ ) || ( $_ =~ /^\.ts/ ) ) {
@F = split (' ');
$TScolor = ( $F[1] == -1 || $F[1] eq "" ) ? $TScolor0 : $F[1] ;
$TSsize = ( $F[2] eq "" ) ? $TSsize0 : $F[2] ;
#print $TSsize;
if ( $F[0] eq ".TS" ) {
#$_ = "<center> <table border=2 bgcolor=$TScolor cellspacing=3><tr><TH>";
$_ = "\n<center>\n<table border=2 bgcolor=$TScolor cellspacing=3>\n";
#$TRcolor = ( $F[1] eq "" ) ? "orange" : $F[3] ;
}
else {
$_ = "<TABLE BORDER=3 bgcolor=$TScolor>";
}
}

$_ =~ s|^\.cap\s|<CAPTION ALIGN=center>\n |;
$_ =~ s|^\.tr\s|<TR>\n <TH ALIGN=LEFT><font $face size=$TSsize> |;
$_ =~ s|^\.TR\s|<TR>\n <TH ALIGN=LEFT bgcolor=orange> <font $face size=$TSsize> |;
$_ =~ s|^\.tr2\s|<TR bgcolor=$TScolor2>\n <TH ALIGN=LEFT><font $face size=$TSsize> |;
$_ =~ s|^\.TR2\s|<TR bgcolor=$TScolor2>\n <TH ALIGN=LEFT bgcolor=orange><font size=$TSsize $face> |;
#$_ =~ s|^\.TR1\s|<TR bgcolor=#ff6699>\n <TH ALIGN=LEFT><font size=$TSsize $face> |;
$_ =~ s|^\.TR1\s|<TR bgcolor=hotpink>\n <TH ALIGN=LEFT><font size=$TSsize $face> |;
$_ =~ s|^\.Tr\s|<TR><TH ALIGN=LEFT bgcolor=#ff33ff><font size=$TSsize $face>\n |;
$_ =~ s|^\.trs6\s|<TR><TH ALIGN=LEFT ><font size=6 $face>|;
$_ =~ s|^\.tr2\s|<TR><TH ALIGN=LEFT Colspan=2>|;
$_ =~ s|^\.tr3\s|<TR><TH ALIGN=LEFT Colspan=3>|;
$_ =~ s|^\.tr4\s|<TR><TH ALIGN=LEFT Colspan=4>|;
$_ =~ s|^\.trs4\s|<TR><TH ALIGN=LEFT ><font $face size=4>|;
$_ =~ s|^\.trs5\s|<TR><TH ALIGN=LEFT ><font $face size=5>|;
$_ =~ s|^\.TE\s*$|</TABLE></center>|;
$_ =~ s|^\.te\s*$|</TABLE>|;

if ( ( $_ =~ /^\.th/ ) || ( $_ =~ /^\.td/ ) ) {
@F = split (' ');
$TDcolor = ( $F[1] == -1 || $F[1] eq "" ) ? "$TScolor" : $F[1] ;
$TDsize = ( $F[2] eq "" ) ? "$TSsize" : $F[2] ;
if ( $F[0] eq ".th" ) {
$_ = "<TH bgcolor=$TDcolor><font $face size=$TDsize>";
}
else {
$_ = "<TD bgcolor=$TDcolor><font $face size=$TDsize>";
}
}

if ( $_ =~ /^\s*<TR/ || $_ =~ /^\s*\.\|\s/ ) {

#$_ =~ s/\s\|n\s/<TD>/g;
#$_ =~ s/\s\|c\s/<TH>/g;
$_ =~ s/\s\|\s/\n <TH ALIGN=LEFT><FONT $face size=$TSsize> /g;
$_ =~ s/\.\|\s/\n <TH ALIGN=LEFT><FONT $face size=$TSsize> /g;
#$_ =~ s/\s\|s4\s/ <TH><FONT $face size=4> /g;
#$_ =~ s/\s\|s5\s/ <TH><FONT $face size=5> /g;
#$_ =~ s/\s\|s6\s/ <TH><FONT $face size=6> /g;
#$_ =~ s/\s\|\|\s/ <TH><FONT $face size=6> /g;
#$_ =~ s/\s\|s7\s/ <TH><FONT $face size=7> /g;

$_ =~ s/\s\|2\s/<TH ALIGN=LEFT colspan=2>/g;
$_ =~ s/\s\|3\s/<TH ALIGN=LEFT colspan=3>/g;
$_ =~ s/\s\|4\s/<TH ALIGN=LEFT colspan=4>/g;
$_ =~ s/\s\|5\s/<TH ALIGN=LEFT colspan=5>/g;
$_ =~ s/\s\|6\s/<TH ALIGN=LEFT colspan=6>/g;

}


#==========================================================
# Started from the beginning of the line and take 1 argument
#==========================================================

#$_ =~ s|^\.lk\s+(\S+)|<link rev=made href=mailto:$1>|;

#==========================================================
# End of line commands
#==========================================================

$_ =~ s|\s\.p\s*$|<p>|;
$_ =~ s|\s\.br\s*$|<br>|;
$_ =~ s|\s\.\s*$|<br>|;

#==========================================================
# Embeddable commands:
# Each dot comand must have an extra space or . after
# The extra space (or .) will be removed.
# It must have exact number of arguments
# It does not take the rest of line as arguments
#==========================================================

#----------------------------------------------------------
# Started from beginning or Embeded commands with 0 argument
#----------------------------------------------------------

#$_ =~ s|(\S+\s+)\.fi[\.\s]|$1<i>|g;
#$_ =~ s|(\S+\s+)\.fb[\.\s]|$1<b>|g;
#$_ =~ s|(\S+\s+)\.ul[\.\s]|$1<u>|g;
#$_ =~ s|(\S+\s+)\.cw[\.\s]|$1<tt>|g;

#$_ =~ s|\./fi[\.\s]|</I>|g;
#$_ =~ s|\./fb[\.\s]|</B>|g;
#$_ =~ s|\./ul[\.\s]|</U>|g;
#$_ =~ s|\./cw[\.\s]|</TT>|g;

#$_ =~ s|\.Fb[\.\s]|</B>|g;
#$_ =~ s|\.Fi[\.\s]|</I>|g;
#$_ =~ s|\.Ul[\.\s]|</U>|g;
#$_ =~ s|\.Cw[\.\s]|</TT>|g;
#$_ =~ s|\.h1[\.\s]|<h1>|g;
#$_ =~ s|\.H1[\.\s]|</h1>|g;
#$_ =~ s|\.h2[\.\s]|<h2>|g;
#$_ =~ s|\.H2[\.\s]|</h2>|g;
#$_ =~ s|\.h3[\.\s]|<h3>|g;
#$_ =~ s|\.H3[\.\s]|</h3>|g;
#$_ =~ s|\.h4[\.\s]|<h4>|g;
#$_ =~ s|\.H4[\.\s]|</h4>|g;
#$_ =~ s|\.h5[\.\s]|<h5>|g;
#$_ =~ s|\.H5[\.\s]|</h5>|g;
#$_ =~ s|\.h6[\.\s]|<h6>|g;
#$_ =~ s|\.H6[\.\s]|</h6>|g;

$_ =~ s|\.F\s|</font>|g;
$_ =~ s|\.F$|</font>|g;

#----------------------------------------------------------
# To avoid conflict in symbol '|', use &pipe; to escape
# To avoid conflict in symbol '.', use ˙ to escape
#----------------------------------------------------------
#$_ =~ s/&pipe;/|/g;
#escapesmbl ( $_ );
#$_ =~ s/˙/./g;

#----------------------------------------------------------
# Started from beginning or Embeded commands with 1 argument
#----------------------------------------------------------

$_ =~ s|\.ps\s+(\d+)|<font $face size=$1> |g;
$_ =~ s|\.clr\s+(#*\w+)\s*|<font $face color=$1> |g;
$_ =~ s|\.select\s+(\w+)\s*|<select name="$1"><br>\n |g;
$_ =~ s|\.text\s+(\w+)\s*|<input type="TEXT" name="$1"><br>\n|g;
$_ =~ s|\.passwd\s+(\w+)\s*|<input type="PASSWORD" name="$1"><br>\n|g;

$_ =~ s|\.img[\.\s]\s*([^<\s]+)|<center><img src="$1"></center>\n|g;
$_ =~ s|\.imgw\s+(\d+)\s+(\S+)\s*|<center><img src="$2" width=$1></center>\n|g;
#$_ =~ s|\.include[\.\s]\s*([^<\s]+)|<object data="$1"></object>|g;

#----------------------------------------------------------
# Started from beginning or Embeded commands with 2 argument
#----------------------------------------------------------

#$_ =~ s|\.hidden\s+(\w+)\s+(\w+)\s*|<input type="HIDDEN" name="$1" value="$2"><br>\n|g;
#$_ =~ s|\.pscolor\s+(\d+)\s+(#*\w+)\s*|<font $face size=$1 color=$2>|g;
$_ =~ s|\.psclr\s+(\d+)\s+(#*\w+)\s*|<font $face size=$1 color=$2> |g;
$_ =~ s|\.clrps\s+(#*\w+)\s+(\d+)\s*|<font $face size=$2 color=$1> |g;

#----------------------------------------------------------
# Started from beginning or Embeded commands with 3 argument
#----------------------------------------------------------

#$_ =~ s|\.ai3\s+(\S+)\s+(\S+)\s+([^<\s]+)|<a href="http:$1"><img: SRC="$2"$3></a>|g;



#======================================================================


#==========================================================
# Following commands take the rest of the line as arguments
# process embedded first, then from the beginning of the line
#==========================================================
#----------------------------------------------------------
# Embeddable Commands that take the rest of line as arguments
#----------------------------------------------------------

#==========================================================
# Remove the .. in the first line, will be put back after
# the embeded dot command convertion
#==========================================================

$dotdeleted = 0 ;
if ( $_ =~ /^\s*\.\./ ) {
$_ =~ s/(^\s*)\.\.(\s*)/$1/;
$dotdeleted = 1 ;
$dothead = "..$2" ;
}

#----------------------------------------------------------
# Remove the . in the first line, will be put back after
# the embeded dot command convertion
#----------------------------------------------------------

if ( $_ =~ /^\s*\./ ) {
$_ =~ s/(^\s*)\.(\s*)/$1/;
$dotdeleted = 1 ;
$dothead = ".$2" ;
}

#----------------------------------------------------------
# Take the rest of line as the arguments
#----------------------------------------------------------
$_ =~ s|\s\.1\s+(\S.*)$|<h1>$1</h1>|;
$_ =~ s|\s\.2\s+(\S.*)$|<h2>$1</h2>|;
$_ =~ s|\s\.3\s+(\S.*)$|<h3>$1</h3>|;
$_ =~ s|\s\.4\s+(\S.*)$|<h4>$1</h4>|;
$_ =~ s|\s\.5\s+(\S.*)$|<h5>$1</h5>|;
$_ =~ s|\s\.6\s+(\S.*)$|<h6>$1</h6>|;

#----------------------------------------------------------
# Embedded: take 1 argument and the rest of the line
#----------------------------------------------------------

$_ =~ s|\.a\s+(\S+)\s+(\S.*)$|<a href="$1">$2</a>\n|;
$_ =~ s|\.A\s+(\S+)\s+(\S.*)$|<center><a href="$1"><font $face
size=6><b>$2</b></a></center>\n|;
#$_ =~ s|\.Aleft\s+(\S+)\s+(\S.*)$|<a href="$1"><font size=6 $face ><b>$2</b></a>|;
#$_ =~ s|\.i\s+(\S+)\s+(\S.*)$|<img src="$1"$2>|;

#----------------------------------------------------------
# Put back dot for those lines that are removed
#----------------------------------------------------------

if ( $dotdeleted == 1) {
$_ =~ s/\S/$dothead$&/ ;
}

$_ =~ s|^\.1\s+(\S.*)$|<h1>$1</h1>\n|;
$_ =~ s|^\.2\s+(\S.*)$|<h2>$1</h2>\n|;
$_ =~ s|^\.3\s+(\S.*)$|<h3>$1</h3>\n|;
$_ =~ s|^\.4\s+(\S.*)$|<h4>$1</h4>\n|;
$_ =~ s|^\.5\s+(\S.*)$|<h5>$1</h5>\n|;
$_ =~ s|^\.6\s+(\S.*)$|<h6>$1</h6>\n|;

#==========================================================
# Commands that start from the beginning of the line
# and take the rest of the line as arguments
#==========================================================

#==========================================================
# If not started with a . just print it
#==========================================================

#if ( $_ !~ /^\s*\./) {print $_ , "\n"; next;}
#$_ =~ s/˙/./g;
#
if ( $_ =~ /^[1-5]/) {
escapesmbl ( $_ );
print "\n";
}
if ( $_ !~ /^\s*\./) {
escapesmbl ( $_ );
print $_ ; next;
}

/^(\s*)(\.\S*)\s*(\S*.*)/;
$ls=$1; # leading spaces are kept
$cmd=$2; # dot command
$argN=$3; # rest of the line

#----------------------------------------------------------
# Take 0 or the whole line
#----------------------------------------------------------

$c = 0; $em = 0; $st = 0; $fi = 0; $fb = 0; $cw = 0; $ul = 0;
if ($cmd =~ /^\.c\s*$/ ) { $c=1; $word="center";}
#if ($cmd =~ /^\.fi\s*$/ ) { $fi=1; $word="i"; }
#if ($cmd =~ /^\.fb\s*$/ ) { $fb=1; $word="b";}
#if ($cmd =~ /^\.cw\s*$/ ) { $cw=1; $word="TT";}
#if ($cmd =~ /^\.ul\s*$/ ) { $ul=1; $word="u";}

if ($c==1||$em==1||$st==1||$fi==1||$fb==1||$cw==1||$ul==1) {
if ( $argN eq "" ) {
$cmd = "<" . $word . ">";
}
else {
$cmd = "<" . $word . ">" . $argN . "</" . $word . ">";
}
}

#----------------------------------------------------------
# Take whole line as the argument
#----------------------------------------------------------

$cmd =~ s|^\.!\s*$|<!-- $argN -->|;
$cmd =~ s|^\."\s*$|<!-- $argN -->|;
$cmd =~ s|\s^\.1\s*$|<h1>$argN</h1>\n|;
$cmd =~ s|\s^\.2\s*$|<h2>$argN</h2>\n|;
$cmd =~ s|\s^\.3\s*$|<h3>$argN</h3>\n|;
$cmd =~ s|\s^\.4\s*$|<h4>$argN</h4>\n|;
$cmd =~ s|\s^\.5\s*$|<h5>$argN</h5>\n|;
$cmd =~ s|\s^\.6\s*$|<h6>$argN</h6>\n|;
$cmd =~ s|^\.t\s*$|<title>$argN</title>\n|;

#----------------------------------------------------------
# Take 1 argument and the rest of line as arguments
# argN is further split into $arg1 and $argN
#----------------------------------------------------------
$argN =~ /(\S*)\s*(\S*.*)/;
$arg1 = $1 ;
$argN = $2 ;

$cmd =~ s|^\.option\s*$|<option value="$arg1">$argN\n|g;
$cmd =~ s|^\.n\s*$|<a name="$arg1">$argN</a>\n |;
$cmd =~ s|^\.a\s*$|<a href="$arg1">$argN</a>\n |;
$cmd =~ s|^\.ah\s*$|<a href="http://$arg1">$argN</a>\n |;
$cmd =~ s|^\.A\s*$|<center><a href="$arg1"><font size=6><b>$argN</b></a></center>\n|;
$cmd =~ s|^\.Aleft\s*$|<a href="$arg1"><font size=6><b>$argN</b></a>|;
$cmd =~ s|^\.form\s*$|<h1><center>$argN</center></h1><FORM METHOD="GET" ACTION=\"$arg1\">\n|;
$cmd =~ s|\.inputtext\s*$|$argN<INPUT TYPE="TEXT" NAME=\"$arg1\"><BR>|;
$cmd =~ s|^\.i\s*$|<img src="$arg1"$argN>|;
$cmd =~ s|^\.\.\s*$|<dt>$arg1<dd>$argN|;
#----------------------------------------------------------
# Take 2 argument and the rest of line as arguments
# argN is further split into $arg2 and $argN
#----------------------------------------------------------

$argN =~ /(\S*)\s*(\S*.*)/;
$arg2 = $1 ;
$argN = $2 ;
$cmd =~ s|^\.radio\s*$|<input type="RADIO" name="$arg1" value="$arg2">$argN\n |g;
$cmd =~ s|^\.checkbox\s*$|<input type="CHECKBOX" name="$arg1" value="$arg2">$argN\n |g;


#----------------------------------------------------------
# Finish Substitution; print the line
#----------------------------------------------------------

#print $ls, $cmd, "\n";


escapesmbl ( $ls );
escapesmbl ( $cmd );
print $ls, $cmd;
}
print "\n<!-- This document is transformed using htxp.pl -->\n";
if ( eof ) {exit; }