Changeset 2819
- Timestamp:
- 2001-11-05T22:49:46+13:00 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugins/HTMLPlug.pm
r2817 r2819 156 156 if ($self->{'description_tags'}) { 157 157 158 my $opencom = '(?:<!--|<!(?:—|—|--))'; 159 my $closecom = '(?:-->|(?:—|—|--)>)'; 160 my $lt = '(?:<|<)'; 161 my $gt = '(?:>|>)'; 162 my $quot = '(?:"|"|”|“)'; 163 158 164 my $found_something = 0; my $top = 1; 159 while ($$textref =~ s/^(.*?) <!--(.*?)-->//s) {165 while ($$textref =~ s/^(.*?)$opencom(.*?)$closecom//s) { 160 166 my $text = $1; 161 167 my $comment = $2; … … 163 169 $self->process_section(\$text, $base_dir, $file, $doc_obj, $cursection); 164 170 } 165 while ($comment =~ s/<([^>]+)>//s) { 171 while ($comment =~ s/$lt(.*?)$gt//s) { 172 166 173 my $tag = $1; 167 174 if ($tag eq "Section") { … … 172 179 $found_something = 1; 173 180 $cursection = $doc_obj->get_parent_section ($cursection); 174 } elsif ($tag =~ /^Metadata name= \"([^\"]+)\"/s) {181 } elsif ($tag =~ /^Metadata name=$quot(.*?)$quot/s) { 175 182 my $metaname = $1; 176 $comment =~ s/^(.*?) <\/Metadata>//s;183 $comment =~ s/^(.*?)$lt\/Metadata$gt//s; 177 184 my $metavalue = $1; 178 185 $metavalue =~ s/^\s+//; 179 186 $metavalue =~ s/\s+$//; 187 # assume that no metadata value intentionally includes 188 # carriage returns or HTML tags (if they're there they 189 # were probably introduced when converting to HTML from 190 # some other format). 191 $metavalue =~ s/[\cJ\cM]/ /sg; 192 $metavalue =~ s/<[^>]+>//sg; 193 $metavalue =~ s/\s+/ /sg; 180 194 $doc_obj->set_utf8_metadata_element($cursection, $metaname, $metavalue); 195 } elsif ($tag eq "Description" || $tag eq "/Description") { 196 # do nothing with containing Description tags 197 } else { 198 # simple HTML tag (probably created by the conversion 199 # to HTML from some other format) - we'll ignore it and 200 # hope for the best ;-) 181 201 } 182 202 } … … 197 217 print $outhandle " of the final closing </Section> tag. This text will\n"; 198 218 print $outhandle " be ignored."; 219 my ($text); 199 220 if (length($$textref) > 30) { 200 221 $text = substr($$textref, 0, 30) . "..."; 222 } else { 223 $text = $$textref; 201 224 } 202 225 $text =~ s/\n/ /isg;
Note:
See TracChangeset
for help on using the changeset viewer.