3 ###############################################################################
5 # Name : list_to_html #
6 # Author : Chris Koeritz #
7 # Rights : Copyright (C) 1996-$now by Author #
11 # Munges multiple files together into one output file with html formatting #
12 # that makes it appropriate for a numbered list. #
14 ###############################################################################
15 # This program is free software; you can redistribute it and/or modify it #
16 # under the terms of the GNU General Public License as published by the Free #
17 # Software Foundation; either version 2 of the License or (at your option) #
18 # any later version. See: "http://www.gruntose.com/Info/GNU/GPL.html" for a #
19 # version of the License. Please send any updates to "fred@gruntose.com". #
20 ###############################################################################
22 require "filename_helper.pl";
24 # this is our default output filename for the html list.
25 local($output_file) = "text_listing.html";
27 # make sure they gave us some files to process.
33 # clear and initialize our output file before doing anything else.
34 open(O_FILE, ">" . $output_file);
36 # add in the boilerplate for an html document and our initial nesting level.
38 <!DOCTYPE html PUBLIC \"-//w3c//dtd html 4.0 transitional//en\">\
41 <title>generated html from list_to_html script</title>\
42 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\
43 <meta name=\"author\" content=\"Fred T. Hamster\">\
50 # now iterate over the list of files and dump them to our output file.
52 foreach $filename (&glob_list(@ARGV)) {
53 $chewed_filename = &basename($filename);
54 $chewed_filename =~ s/_/ /g;
55 $chewed_filename =~ s/\.[a-zA-Z][a-zA-Z][a-zA-Z]$//;
56 $chewed_filename =~ s/\.[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z]$//;
57 #print "new filename is $chewed_filename\n";
58 &do_dump($filename, $chewed_filename, $output_file);
61 open(O_FILE, ">>" . $output_file);
63 # return from first nesting and close out the document.
64 print O_FILE "\n</ol>\
72 ############################################################################
74 # prints help out on using this amazing program.
79 list_to_html: this program needs a set of filenames to print out in html
80 list format. the resulting information will be placed in a file called
81 \"$output_file\" in the current directory.
86 ############################################################################
88 # do_dump: prints the contents of the first parameter's file out by
89 # concatenating it onto the second parameter's file. since it's an append,
90 # if you mess up, the file will at least not be overwritten.
94 ($to_dump, $chewed_name, $output_file) = @_;
96 # print "dumpfile=$to_dump and chewed=$chewed_name and outfile=$output_file\n";
98 if (&basename($to_dump) eq &basename($output_file)) {
99 # we don't ever dump to the same file as we're outputting to. that would
100 # be quite silly and would make the file pretty useless, as well as
101 # rendering the original file corrupted possibly.
113 $header_copy = $header;
114 $header_copy =~ s/%1/$chewed_name/;
116 ##print $header_copy;
118 open(TO_DUMP, "<$to_dump");
119 open(OUT, ">>$output_file");
121 print OUT $header_copy;
126 #for ($i = 0; $i < length($line); $i++) {
127 #$curr_char = substr($line, $i, 1);
128 #print "[$curr_char]";
131 local($curr_char) = 0;
132 #print "start len=" . length($line) . "\n";
135 chop $line; # remove end of line char(s).
136 $curr_char = substr($line, length($line) - 1, 1);
137 # get new last char in string.
138 } while ( ($curr_char eq "\r") || ($curr_char eq "\n") );
139 local($do_print) = 1;
140 if (length($line) == 0) {
141 #continue; # skip the first blank lines.
142 $do_print = 0; #no continue statement??
145 # a non-blank line has been seen. now we reset our flag so we stop
146 # checking for blank lines.
148 if ($do_print) { print OUT "<li>" . $line . "</li>\n"; }