#
# this web page has a good reference on writting this stuff
#
#    #http://perl.apache.org/docs/general/perl_reference/perl_reference.html#use____require____do_____INC_and__INC_Explained
#



sub html_to_dhtml {
   # 
   # convert raw html to displayable HTML
   # ie
   #     <h1>Title</h1>
   # becomes
   #     &lt;h1&gtTitle&lt;/h1&gt;
   #
   # get the argument passed to us 
   #
   my $content_html=$_[0];
   #
   # convert the RAW HTML to html we can display
   #
   # ie ">" is changed to "&gt;"
   # ie "<" is changed to "&lt;"
   # ie "&" is changed to "&amp;"
   #
   $content_html=~s/&/&amp;/g;
   $content_html=~s/</&lt;/g;
   $content_html=~s/>/&gt;/g;
   #
   # all done return the value
   #
   return $content_html;
}






#
# a function to put each of these html tags at the begining of a line
# ie: but a <br> tag in front of them
#
sub mikes_fix_html {
   my @mikes_tags=('html',
                   '/html',
                   'frame',
                   '/frameset',
                   '/frameset',
                   'noframes',
                   '/noframes',
                   'link',
                   'embed',
                   'p',
                   '/p',
                   'br',
                   '/br',
                   'li',
                   'ol',
                   '/ol',
                   'ul',
                   '/ul',
                   'hr',
                   'head',
                   '/head',
                   'title',
                   'center',
                   '/center',
                   'blockquote',
                   '/blockquote',
                   'body',
                   '/body',
                   'script',
                   '/script',
                   'noscript',
                   'table',
                   '/table',
                   'th',
                   'tr',
                   '/tr',
                   'td',
                   '/td',
                   'div',
                   '/div',
                   'span',
                   '/span',
                   'form',
                   '/form',
                   'input',
                   'option',
                   '/option',
                   'select',
                   '/select',
                   'meta',
                   'a',
                   'h1',
                   'h2',
                   'h3',
                   'h4',
                   'img'
                   );
   #
   # pick up the data that was passed to us
   #
   my $content_html=$_[0];
   #
   # loop thru each tag
   #
   foreach (@mikes_tags) {
      #
      # for each tag found put a <br> in front of the tag
      # note the tag has the format
      # 
      #    < whitespace tag whitespace
      #
      # and it is changed to
      #
      #     <br>< whitespace tag whitespace
      #
      $content_html=~s/&lt;([\s]*)$_([\s>]*)/<br>&lt;$1$_$2/gi;
   } 
   #
   # comments are handled differently
   #
   $content_html=~s/&lt;!--/<br>&lt;!--/gi;
   $content_html=~s/--&gt;/<br>--&gt;/gi;
   return $content_html;
}
1;