Changeset 9582 for trunk/gsdl


Ignore:
Timestamp:
2005-04-07T14:04:37+12:00 (19 years ago)
Author:
jrm21
Message:

couple of fixes:

" and others" in the author field => 'et. al.'
make whitespace optional around the = sign

use the booktitle or journal name if the entry has no 'title'

File:
1 edited

Legend:

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

    r9120 r9582  
    117117    # BibTex names are taken from the "Local Guide to Latex" Graeme
    118118    # McKinstry.  Metadata names are consistent with ReferPlug.
     119
     120    # The author metadata will be stored as one "Creator" entry, but will
     121    # also be split up into several individual "Author" fields.
    119122
    120123    my %field = (
     
    203206   
    204207    # otherwise, parse the metadata out of this line
    205     next unless ($line =~ /^\s*(\w+)\s+=\s+(.*)/);
     208    next unless ($line =~ /^\s*(\w+)\s*=\s*(.*)/);
    206209    $entryname = lc($1);
    207210    $value = $2;
     
    261264       
    262265        # take care of "et al."...
    263         $value =~ s/(\s+et\.?\s+al\.?)\s*$//;
    264         my $etal=$1;
    265         $etal="" if (!defined ($etal));
     266        my $etal='';
     267        if ($value =~ s/\s+(and\s+others|et\.?\s+al\.?)\s*$//i) {
     268        $etal=' <em>et. al.</em>';
     269        }
    266270        # und here for german language...
    267271        # don't use brackets in pattern, else the matched bit becomes
     
    322326        }
    323327        my $wholename="$first $von $last $jr";
    324         $wholename =~ s/ $//; $wholename =~ s/\s+/ /g;
     328        $wholename =~ s/\s+/ /g; # squeeze multiple spaces
     329        $wholename =~ s/ $//;
    325330        push (@formattedlist, $wholename);
    326331        my $fullname = "$last";
     
    330335
    331336        # Add each name to set of Authors
    332         # force utf8 pragma so that \w matches in this scope
    333         use utf8;
    334337        $doc_obj->add_utf8_metadata ($cursection, "Author", $fullname);
    335338        }
     
    353356    }
    354357
    355 
    356358    # Add the various fields as metadata   
    357359    $doc_obj->add_utf8_metadata ($cursection, $name, $value);
     360    }
     361
     362    # for books and journals...
     363    if (!exists $metadata{'title'}) {
     364    my $name=$field{'title'}; # get Greenstone metadata name
     365    my $value;
     366    if (exists $metadata{'booktitle'}) {
     367        $value=$metadata{'booktitle'};
     368    } elsif (exists $metadata{'journal'}) {
     369        $value=$metadata{'journal'};
     370    }
     371    if ($value) {
     372        $doc_obj->add_utf8_metadata ($cursection, $name, $value);
     373    }
    358374    }
    359375
Note: See TracChangeset for help on using the changeset viewer.