Changeset 16301
- Timestamp:
- 2008-07-04T12:57:26+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/perllib/plugins/TextPlugin.pm
r16104 r16301 91 91 # in from another plugin) 92 92 if (!defined $metadata->{'Title'}) { 93 my ($title) = $$textref; 94 $title =~ /^\s+/s; 95 if (defined $self->{'title_sub'} && 96 $self->{'title_sub'}) {$title =~ s/$self->{'title_sub'}//;} 97 $title =~ /^\s*([^\n]*)/s; $title=$1; 98 if (length($title) > 100) { 99 $title = substr ($title, 0, 100) . "..."; 100 } 101 $title =~ s/\[/[/g; 102 $title =~ s/\[/]/g; 103 $title =~ s/\</</g; 104 $title =~ s/\>/>/g; 93 my $title = $self->get_title_metadata($textref); 105 94 $doc_obj->add_utf8_metadata ($cursection, "Title", $title); 106 95 } … … 110 99 # insert preformat tags and add text to document object 111 100 $self->text_to_html($textref); # modifies the text 112 $doc_obj->add_utf8_text($cursection, $$textref); #$doc_obj->add_utf8_text($cursection, "<pre>\n$$textref\n</pre>");101 $doc_obj->add_utf8_text($cursection, $$textref); 113 102 114 103 return 1; 104 } 105 106 sub get_title_metadata { 107 my $self = shift (@_); 108 my ($textref) = @_; 109 110 my ($title) = $$textref; 111 $title =~ /^\s+/s; 112 if (defined $self->{'title_sub'} && $self->{'title_sub'}) { 113 $title =~ s/$self->{'title_sub'}//; 114 } 115 $title =~ /^\s*([^\n]*)/s; $title=$1; 116 if (length($title) > 100) { 117 $title = substr ($title, 0, 100) . "..."; 118 } 119 $title =~ s/\[/&\#91;/g; 120 $title =~ s/\[/&\#93;/g; 121 $title =~ s/\</&\#60;/g; 122 $title =~ s/\>/&\#62;/g; 123 124 return $title; 115 125 } 116 126 … … 200 210 } 201 211 close(TEXT); # close the file 202 203 # convert the text 212 213 # Get the title before embedding the text in pre tags 214 my $title = $self->get_title_metadata(\$text); 215 216 # Now convert the text 204 217 $self->text_to_html(\$text); 205 206 #print STDERR "****output_filename: $output_filename\n"; 207 #print STDERR "****text: $text\n"; 208 218 209 219 # try creating this new file writing and try opening it for writing, else exit with error value 210 220 unless(open(HTML, ">$output_filename")) { # open the new html file for writing … … 212 222 return ""; # no filename 213 223 } 214 # write the html contents in text out to the file 215 print HTML $text; 224 # write the html contents of the text (which is embedded in <pre> tags) out to the file with proper enclosing tags 225 print HTML "<html>\n<head>\n<title>$title</title>\n</head>\n<body>\n"; 226 print HTML $text; 227 print HTML "\n</body>\n</html>"; 216 228 close HTML; 217 229
Note:
See TracChangeset
for help on using the changeset viewer.