Changeset 3092 for trunk/gsdl


Ignore:
Timestamp:
2002-04-23T11:30:11+12:00 (22 years ago)
Author:
sjboddie
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/convert_toc.pl

    r3081 r3092  
    33# convert_toc.pl converts old <<TOC>> marked up files to use the new
    44# <Section> syntax (suitable for processing by HTMLPlug -description_tags
     5
     6use File::Basename;
    57
    68my $level = 0;
     
    1921  # fix images
    2022  $content =~ s/&lt;&lt;I&gt;&gt;\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
    2240  # process section title
    2341  while ($content =~ s/(?:<P[^>]*>|<BR>)(?:\s*<\/?[^>]*>)*?&lt;&lt;TOC(\d+)&gt;&gt;(.*?)(?:\s*<\/?[^>]*>)*?\s*(<\/P[^>]*>|<BR>)/process_toc ($1, $2)/sige) {}
     
    3957  my $toc = '';
    4058 
    41   $title =~ s/\n/ /g;
    4259  $title =~ s/<[^>]+>//g;
    4360  $title =~ s/^\s+//;
    4461  $title =~ s/\s+$//;
     62  $title =~ s/\n/ /g;
    4563
    4664  $toc .= "\n<!--\n";
Note: See TracChangeset for help on using the changeset viewer.