#!\c:\apps\perl\bin\perl.exe

# Create a valid sgm charent file from all 
# characters in the charmap.sgm file.
# For just the custom tcp characters, use the program
# tcp-charmap-entmaketcp-sgm.pl.

# At the command line type:
# tcp-charmap-entmake-sgm.pl > newentfile.ent


#use strict;

#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 sgm ent file

print "<!-- Character entity set. Typical invocation:\n";
print "   <!ENTITY % EEBOcharall PUBLIC\n";
print "     \"EEBO 2008-1//ENTITIES EEB-ALL//EN\">\n";
print "   %EEBOcharall;\n";
print "-->\n\n";
print "<!-- Generated by tcp-charmap-entmake-sgm-all.pl on " . localtime(time) . " -->\n\n";
print "<!-- Please make character changes to charmap.sgm, and then run tcp-charmap-entmake-sgm-all.pl to generate this ent file. -->\n\n";
   
foreach $entity (@entities) {
   #get entity name and comment, then print
   my $ent = content_attr('ENT','TCP');
   my $comment = join(" ",content_attr('EQUIV','DESC'), content_tag(COMMENT));
   #TODO check for multiple EQUIV and COMMENT tags
   print "<!ENTITY $ent SDATA \"&$ent\;\"--=$comment-->\n";
}
print "\n";
