#!\c:\apps\perl\bin\perl.exe

#program makes an htm file that shows all
#the characters in the charmap.sgm file.

#include tcp character map subroutines
require "C:/code/Perl/Eebo/tcp-charmap-include.pm";

#file containing character map
my $charactermap = "C:/code/charents/charmap.sgm"; 

#put character map into a perl array
charmap_array($charactermap); 

# create file headers

print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
print "<HTML>\n<HEAD>\n<TITLE>Text Creation Partnership Character Entity List</TITLE>\n";
print "<STYLE TYPE=\"text/css\">\n<!--\n";
print "BODY { font-family: Arial Unicode MS }\n";
print "TABLE {  }\n";
print "TR {  }\n";
print "TD {  }\n";
print "-->\n</STYLE>\n</HEAD>\n<BODY>\n";
print "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
print "<THEAD><B>Text Creation Partnership Character Entity List generated by tcp-charmap-htm.pl on " . localtime(time) ."</B></THEAD>\n";
print "<TR><TH>Entity</TH><TH>Displays as</TH><TH>U+</TH><TH>Set</TH><TH>Description or Display Equivalent</TH></TR>\n";

#cycle through entities

foreach $entity (@entities) {
   my $entsgm = content_attr('ENT','TCP');
   my $entset = content_attr('ENT','SRC');
   my $unic = substr(content_attr('EQUIV','UNIC'),1); #remove initial U
   
   #use Arial Unicode MS entity
   my $entview = content_attr_known('REPL','TXT','SUP','Arial Unicode MS');
   #if no Arial entry, use default entity
   if (! $entview) {
      $entview = content_attr_known('REPL','TXT','SUP','default');
   }
   
   my $equivdesc = content_attr('EQUIV','DESC');
   if ($equivdesc) {
      $equivdesc = "<font color=\"red\">" . $equivdesc . "</font>";
   }
   my $repldesc = content_attr('REPL','DESC');
   if ($repldesc) {
      $repldesc = "<font color=\"blue\">display " . $repldesc . "</font>";
   }
   my $comment = content_tag('COMMENT');
   
   my $description = join(" ", $equivdesc, $repldesc, $comment);
   #TODO check for multiple EQUIV and COMMENT tags
   
   #put a character in to show combining usage 
   #for entities beginning with cmb.
   if ($entsgm =~ /^cmb/) {
      $entview = 'o' . $entview;
   }
   
   print "<TR><TD>$entsgm</TD><TD>$entview</TD><TD>$unic</TD><TD>$entset</TD><TD>$description</TD></TR>\n";
}

print "</TABLE>\n</BODY>\n";
