Changeset 7019


Ignore:
Timestamp:
2004-03-11T12:32:01+13:00 (20 years ago)
Author:
jrm21
Message:

fall back gracefully if -use_sections argument was given but no Sections can
be found.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/PDFPlug.pm

    r6408 r7019  
    8080             "allow_extra_options")) {
    8181
    82     print STDERR "\nIncorrect options passed to PDFPlug, check your collect.cfg configuration file\n";
    8382    local $self = new ConvertToPlug($class, @_, "-title_sub", '^(Page\s+\d+)?(\s*1\s+)?');
     83    my $outhandle=$self->{'outhandle'};
     84    print $outhandle "\nIncorrect options passed to PDFPlug, check your collect.cfg configuration file\n";
    8485    $self->print_txt_usage("");  # Use default resource bundle
    85     die "\n";
     86    exit 1;
    8687    }
    8788
     
    158159sub process {
    159160    my $self = shift (@_);
     161    my $outhandle=$self->{'outhandle'};
     162
    160163    if ($self->{'use_sections'}
    161164    && $self->{'converted_to'} eq "HTML") {
    162165
    163     print STDERR "PDFPlug: Calculating sections...\n";
     166    print $outhandle "PDFPlug: Calculating sections...\n";
    164167    my $textref=$_[0];
    165168
     
    167170    my @sections = split('<a name=', $$textref);
    168171
    169     shift @sections; # don't need HTML header, etc
     172    if (scalar (@sections) == 1) { #only one section - no split!
     173        print $outhandle "PDFPlug: warning - no sections found\n";
     174    } else {
     175        shift @sections; # don't need HTML header, etc
     176    }
     177
    170178    # handle first section specially for title? Or all use first 100...
    171179   
     
    183191    $title =~ s/\s\S*$/.../;
    184192
    185     my $top_section = "<!--<Section>\n<Metadata name=\"Title\">$title</Metadata>\n-->\n <!--</Section>-->\n";
     193    my $top_section;
     194    if (scalar (@sections) == 1) { # no sections found
     195        $top_section=$sections[0];
     196        @sections=();
     197    } else {
     198        $top_section = "<!--<Section>\n<Metadata name=\"Title\">$title</Metadata>\n-->\n <!--</Section>-->\n";
     199    }
    186200
    187201    # add metadata per section...
     
    204218    }
    205219
    206     my $outhandle = $self->{'outhandle'};
    207220    print $outhandle "PDFPlug: passing $_[3] on to $self->{'converted_to'}Plug\n"
    208221    if $self->{'verbosity'} > 1;
Note: See TracChangeset for help on using the changeset viewer.