Changeset 3092 for trunk/gsdl
- Timestamp:
- 2002-04-23T11:30:11+12:00 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/convert_toc.pl
r3081 r3092 3 3 # convert_toc.pl converts old <<TOC>> marked up files to use the new 4 4 # <Section> syntax (suitable for processing by HTMLPlug -description_tags 5 6 use File::Basename; 5 7 6 8 my $level = 0; … … 19 21 # fix images 20 22 $content =~ s/<<I>>\s*(\w+\.(?:png|jpe?g|gif))\s*(.*?)<\/p>/<center><img src=\"$1\"><br>$2<\/center><\/p>\n/igs; 21 23 24 # may need to rename image files if case isn't consistent 25 # (i.e. collections prepared on windows may have images named 26 # AAA.GIF which are linked into the HTML as aaa.gif) 27 my $image_file = $1; 28 my $dirname = &File::Basename::dirname($ARGV[0]); 29 if (!-e "$dirname/$image_file") { 30 # try all lower case 31 my $image_file_new = lc($image_file); 32 if (-e "$dirname/$image_file_new") { 33 print STDERR "renaming $dirname/$image_file --> $dirname/$image_file_new\n"; 34 rename ("$dirname/$image_file", "$dirname/$image_file_new"); 35 } else { 36 print STDERR "ERROR**** $dirname/$image_file does not exist\n"; 37 } 38 } 39 22 40 # process section title 23 41 while ($content =~ s/(?:<P[^>]*>|<BR>)(?:\s*<\/?[^>]*>)*?<<TOC(\d+)>>(.*?)(?:\s*<\/?[^>]*>)*?\s*(<\/P[^>]*>|<BR>)/process_toc ($1, $2)/sige) {} … … 39 57 my $toc = ''; 40 58 41 $title =~ s/\n/ /g;42 59 $title =~ s/<[^>]+>//g; 43 60 $title =~ s/^\s+//; 44 61 $title =~ s/\s+$//; 62 $title =~ s/\n/ /g; 45 63 46 64 $toc .= "\n<!--\n";
Note:
See TracChangeset
for help on using the changeset viewer.