Changeset 318 for trunk/gsdl
- Timestamp:
- 1999-06-30T16:01:06+12:00 (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugins/HBPlug.pm
r317 r318 31 31 sub HB_read_html_file { 32 32 my $self = shift (@_); 33 my ($htmlfile ) = @_;33 my ($htmlfile, $text) = @_; 34 34 35 35 # load in the file 36 36 if (!open (FILE, $htmlfile)) { 37 37 print STDERR "ERROR - could not open $htmlfile\n"; 38 return ""; 39 } 38 return; 39 } 40 41 my $foundbody = 0; 42 $self->HB_gettext (\$foundbody, $text, FILE); 43 close FILE; 44 45 # just in case there was no <body> tag 46 if (!$foundbody) { 47 $foundbody = 1; 48 open (FILE, $htmlfile) || return; 49 $self->HB_gettext (\$foundbody, $text, FILE); 50 close FILE; 51 } 52 } 53 54 sub HB_gettext { 55 my $self = shift (@_); 56 my ($foundbody, $text, $handle) = @_; 40 57 41 58 my $line = ""; 42 my $file = ""; 43 my $foundbody = 0; 44 while (defined ($line = <FILE>)) { 59 while (defined ($line = <$handle>)) { 45 60 # look for body tag 46 if (!$ foundbody) {61 if (!$$foundbody) { 47 62 if ($line =~ s/^.*<body[^>]*>//i) { 48 $ foundbody = 1;63 $$foundbody = 1; 49 64 } else { 50 65 next; 51 66 } 52 67 } 53 68 54 69 # check for symbol fonts 55 70 if ($line =~ /<font [^>]*?face\s*=\s*\"?(\w+)\"?/i) { 56 71 my $font = $1; 57 print STDERR "HBPlug::HB_ read_html_file- warning font $font used\n"72 print STDERR "HBPlug::HB_gettext - warning font $font used\n" 58 73 if ($font !~ /^arial$/i); 59 74 } 60 61 75 62 76 $line =~ s/<\/p>//ig; # remove </p> tags … … 67 81 &html::convertcharentities ($line); 68 82 69 $file .= $line; 70 } 71 close FILE; 72 73 $file =~ s/\s+/ /g; # remove \n's 74 75 return $file; 83 $$text .= $line; 84 } 85 $$text =~ s/\s+/ /g; # remove \n's 76 86 } 77 87 … … 144 154 145 155 # read in the file and do basic html cleaning (removing header etc) 146 my $html = $self->HB_read_html_file ($htmlfile); 156 my $html = ""; 157 $self->HB_read_html_file ($htmlfile, \$html); 147 158 148 159 # create a new document
Note:
See TracChangeset
for help on using the changeset viewer.